GraphlinkGeneratorBuilder class

A build_runner Builder that generates a fully typed GraphQL client from .graphql / .graphqls schema files inside lib/.

GraphLink reads your GraphQL schema and emits:

  • Typed response classes for every query, mutation, and subscription
  • Input classes with immutable fields and named-parameter constructors
  • Enum classes with toJson / fromJson
  • A GraphLinkClient with .queries, .mutations, and .subscriptions namespaces
  • HTTP and WebSocket adapters (Dio or package:http)

This builder is normally invoked through build_runner. For project-wide or CI generation the standalone glink CLI is recommended instead — it supports JSON and YAML configs, watch mode, and multi-language targets.

Minimal build.yaml

targets:
  $default:
    builders:
      graphlink|graphlinkGeneratorBuilder:
        options:
          packageName: my_app
          generateAllFieldsFragments: true
          autoGenerateQueries: true

Supported options

Option Type Default
packageName string
httpAdapter "http" | "dio" | "none" "http"
generateAdapters bool true
generateAllFieldsFragments bool false
autoGenerateQueries bool false
autoGenerateQueriesDefaultAlias string null
defaultAlias string null
operationNameAsParameter bool false
nullableFieldsRequired bool false
immutableInputFields bool true
immutableTypeFields bool true
generateUiTypes bool false
generateUiInputs bool false
appLocalizationsImport string null
identityFields string[] []
disableCache bool false

Any additional string entries are treated as scalar → Dart type mappings (e.g. ID: String, Float: double). The GraphQL built-in scalars are pre-seeded.

Constructors

GraphlinkGeneratorBuilder(BuilderOptions options)
Creates a builder from the given BuilderOptions.

Properties

assets List<AssetId>
Resolved schema asset IDs collected during initAssets.
final
buildExtensions Map<String, List<String>>
Mapping from input file extension to output file extensions.
no setter
hashCode int
The hash code for this object.
no setterinherited
logger → Logger
Logger used to report generation progress and errors.
final
options → BuilderOptions
The raw build.yaml options passed to this builder.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
typeMappings Map<String, String>
Scalar-to-Dart type mappings, seeded with the GraphQL built-in scalars. Any unknown string entries in build.yaml options are merged in at build time, allowing custom scalars to be mapped without a separate config key.
final

Methods

build(BuildStep buildStep) Future<void>
Runs the GraphLink code generator for the current BuildStep.
initAssets(BuildStep buildStep) Future<void>
Populates assets with all .graphql and .graphqls files found under lib/ for the current BuildStep.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readSchema(BuildStep buildStep) Future<String>
Reads and concatenates the contents of all schema assets into a single GraphQL document string.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

inputFiles → Glob
Glob that matches .graphql schema files under lib/.
final
inputFiles2 → Glob
Glob that matches .graphqls schema files under lib/.
final

Constants

outputDir → const String
Output directory for generated Dart files.