Build dart types from a GraphQL schema.
Artemis is a code generator that looks for
*.schema.json (GraphQL Introspection Query response schema) and builds
.api.dart files typing that schema. That's similar to what Apollo does.
Add the following to your
dev_dependencies: artemis: <1.0.0 build_runner: ^1.5.0 json_serializable: ^3.0.0
pub packages get
flutter packages get
artemis will generate the API file for you by running:
pub run build_runner build
flutter pub run build_runner build
If your schema uses custom scalars, they must be defined on
build.yaml file on the root the project. If it needs a custom parser (to decode from/to json), the
custom_parser_import path must be set and the file must implement both
fromDart___toGraphQL___ constant functions.
targets: $default: builders: artemis: options: custom_parser_import: 'package:graphbrainz_example/coercers.dart' scalar_mapping: - graphql_type: Date dart_type: DateTime
See examples for more information and configuration options.