Installation¶
Shalom ships a Rust-based CLI for code generation and Dart packages for runtime support. This guide covers the minimal setup for a Flutter app using Shalom's declarative annotation API.
Prerequisites¶
- Rust toolchain (for the CLI)
- Flutter SDK (Shalom's declarative widgets are Flutter-only)
Install the CLI¶
The command installs the shalom binary on your PATH.
Add Dart dependencies¶
Or add them via the Flutter CLI:
package:shalomexposesShalomRuntimeClient, links (HttpLink,WebSocketLink), response types, and cache helpers.package:shalom_flutterexposesShalomProvider/ShalomScope, generated widget base classes, fragment scopes, and the debug panel.package:shalom_annotationsprovides@Query,@Mutation,@Subscription, and@Fragment, which the codegen scans for.
Project layout¶
The codegen scans your Dart/Flutter source tree for classes annotated with
@Query / @Mutation / @Subscription / @Fragment. You still need a
GraphQL schema file schema.graphql for validation and type generation. A common layout is:
my_flutter_app/
├── lib/
│ ├── graphql/
│ │ └── schema.graphql # GraphQL schema
│ ├── albums_page.dart # @Query widget
│ ├── album_widget.dart # @Fragment widget
│ └── __graphql__/ # Generated code (auto-created)
├── shalom.yml # Optional config (custom scalars, etc.)
└── pubspec.yaml
Generated files are written next to their source files under a __graphql__
directory (for example lib/__graphql__/albums_page.widget.shalom.dart).
Do not edit files under __graphql__ directly.
optional shalom.yml
The shalom.yml configuration is optional unless you need custom scalars mappings or custom output options.
CLI usage¶
Generate code once:
Watch for changes and re-generate on save:
Both commands scan .graphql schema files and annotated .dart files under
the given path (skipping generated __graphql__ directories).