Dartpollo0.1.0-alpha.6
Documentation
On this page

Integration modes

Choose what Dartpollo generates based on the client you use.

Generation settings

generate_helpers and generate_queries both default to true.

HelpersQueriesGenerated resultUse this when
falsefalseResponse, input, enum, and fragment typesAnother tool owns the request document
falsetrueTypes, arguments, operation name, and DocumentNodeUsing package:graphql or another AST-compatible client
truefalseDocuments and Dartpollo wrappers are still emittedAvoid this ambiguous combination
truetrueAll generated artifacts plus GraphQLQuery wrappersUsing the optional Dartpollo clients

Helpers require operation documents, so generate_helpers: true still causes constants to be emitted when generate_queries: false.

Models only

build.yaml

options:
  generate_helpers: false
  generate_queries: false

This removes the Dartpollo import and query wrapper. Parse a data map directly:

lib/main.dart

final viewer = Viewer$Query.fromJson({
  'viewer': {'id': 'user-1', 'login': 'octocat'},
});

No operation constant or argument class is available in this mode, so application code must supply its own document and variable map.

Client-independent documents

build.yaml

options:
  generate_helpers: false
  generate_queries: true
  optimize_document_nodes: false

This mode generates operation documents and names:

lib/generated/viewer.graphql.dart

final VIEWER_QUERY_DOCUMENT_OPERATION_NAME = 'Viewer';
final VIEWER_QUERY_DOCUMENT = DocumentNode(/* generated AST */);

Keep optimization false in alpha.6; see document limitations.

Follow the complete package:graphql guide for document, operationName, parserFn, and typed variables.

Dartpollo helpers

build.yaml

options:
  generate_helpers: true
  generate_queries: true

A wrapper such as ViewerQuery exposes document, operationName, getVariablesMap, and parse to DartpolloClient:

lib/main.dart

final response = await client.execute(ViewerQuery());
print(response.data?.viewer.login);

Follow the Dartpollo client guide to execute these helpers.

Client compatibility

Choose one runtime per package: graphql 5.2.x requires gql_dedupe_link 2.x, while Dartpollo alpha.6 requires 4.x. These versions cannot be installed together. The generator works with either client.