artemis 0.1.3 artemis: ^0.1.3 copied to clipboard
Build dart types from a GraphQL schema (using Introspection Query).
Artemis
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.
Installation #
Add the following to your pubspec.yaml
file:
dev_dependencies:
artemis: <1.0.0
build_runner: ^1.5.0
json_serializable: ^3.0.0
ℹ️ Note that
build_runner
andjson_serializable
are required!
Then run:
pub packages get
or
flutter packages get
Now artemis
will generate the API file for you by running:
pub run build_runner build
or
flutter pub run build_runner build
Custom Scalars #
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 fromGraphQL___ToDart___
and 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.