MIT License PRs Welcome Watch on GitHub Star on GitHub Watch on GitHub Discord

A package for Dart code generation from GraphQL source.

Builders in this package let you build your GraphQL requests and view the response in a type-safe way.

Usage example

See the gql_example_cli or gql_example_flutter for usage examples.

Provided builders

ast_builder

Generates an AST representation of a GraphQL Document

data_builder

Generates a typed view of your data.

var_builder

Creates data classes for any GraphQL variables used in a query or fragment.

schema_builder

Creates data classes from your specified graphql schema.

Configuration

type_overrides: [Map] Specify how scalar types should be serialized

Example:

type_overrides:
    CustomStringScalar:
      name: String
     CustomField:
       name: CustomField
       import: 'package:mypackage/custom_field.dart'

enum_fallbacks: [Map] Specify fallback values to enum values in order to not break the serializer when new enum values are added to the schema and the client has not updated to the new schema yet.

global_enum_fallbacks: [bool] Add a generated fallback value for each enum value (except for ones that have a custom fallback value specified in the enum_fallbacks map). Defaults to false.

Example:

global_enum_fallbacks: true # add a generated fallback value to all enums
enum_fallbacks:
    MyEnumType: OTHER   # except for the type 'MyEnumType', use the value 'OTHER' as fallback there

serializer_builder

Creates built_value serializers for each built_value class.

Features and bugs

Please file feature requests and bugs at the issue tracker.

Libraries

gql_build