Skip to content
Build dart types from a GraphQL schema
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
example
lib Make interfaced objects override resolveType Jun 11, 2019
test
tool
.gitignore
CHANGELOG.md
LICENSE
README.md
analysis_options.yaml
build.yaml
pubspec.lock
pubspec.yaml

README.md

Artemis

Pub Package

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 and json_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.

You can’t perform that action at this time.