GraphQL class

A Dart implementation of a GraphQL server.

Constructors

GraphQL(GraphQLSchema schema, {bool introspect = true, bool validate = false, FutureOr<T> defaultFieldResolver<T>(T, String?, Map<String, dynamic>)?, List<GraphQLType> customTypes = const <GraphQLType>[]})
Binds a schema to an executor.

Properties

customTypes → List<GraphQLType>
Any custom types to include in introspection information.
final
defaultFieldResolver → FutureOr<T> Function<T>(T, String?, Map<String, dynamic>)?
An optional callback that can be used to resolve fields from objects that are not Maps, when the related field has no resolver.
final
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
validate → bool
Whether a document is checked against the schema before it runs.
final

Methods

coerceArgumentValues(GraphQLObjectType objectType, SelectionContext field, Map<String?, dynamic> variableValues) → Map<String, dynamic>
Coerces the arguments written on field against the ones its definition declares.
coerceVariableValues(GraphQLSchema schema, OperationDefinitionContext operation, Map<String, dynamic> variableValues) → Map<String, dynamic>
Coerces the incoming variableValues against the operation's declared variable definitions.
collectFields(DocumentContext document, GraphQLObjectType? objectType, SelectionSetContext selectionSet, Map<String?, dynamic> variableValues, {Set<String?>? visitedFragments, GraphQLObjectType? parentType}) → Map<String?, List<SelectionContext>>
Groups the selections of selectionSet by response key.
completeValue(DocumentContext document, String? fieldName, GraphQLType fieldType, List<SelectionContext> fields, dynamic result, Map<String, dynamic> variableValues, Map<String, dynamic> globalVariables, {List<List> lazy = const []}) → Future
Shapes a resolved value into its response form, following the field type.
convertType(TypeContext ctx, {bool usePolymorphicName = false, GraphQLObjectType? parent}) → GraphQLType
Resolves a type reference parsed from a query against the schema.
createSourceEventStream(DocumentContext document, OperationDefinitionContext subscription, GraphQLSchema schema, Map<String?, dynamic> variableValues, dynamic initialValue) → Future<Stream>
Resolves the single root field of a subscription into its event stream.
doesFragmentTypeApply(GraphQLObjectType? objectType, TypeConditionContext fragmentType, {GraphQLObjectType? parentType}) → bool
Whether a fragment's type condition holds for objectType.
executeField(DocumentContext document, String? fieldName, GraphQLObjectType objectType, dynamic objectValue, List<SelectionContext> fields, GraphQLType fieldType, Map<String, dynamic> variableValues, Map<String, dynamic> globalVariables, {List<List> lazy = const []}) → Future
Resolves one field: coerces its arguments, calls its resolver, then completes the value against fieldType.
executeMutation(DocumentContext document, OperationDefinitionContext mutation, GraphQLSchema schema, Map<String, dynamic> variableValues, dynamic initialValue, Map<String, dynamic> globalVariables) → Future<Map<String?, dynamic>>
Executes a mutation operation and answers its data map.
executeQuery(DocumentContext document, OperationDefinitionContext query, GraphQLSchema schema, Map<String, dynamic> variableValues, dynamic initialValue, Map<String, dynamic> globalVariables) → Future<Map<String, dynamic>>
Executes a query operation and answers its data map.
executeRequest(GraphQLSchema schema, DocumentContext document, {String? operationName, Map<String, dynamic> variableValues = const <String, dynamic>{}, dynamic initialValue, Map<String, dynamic> globalVariables = const <String, dynamic>{}}) → Future
Executes an already-parsed document against schema.
executeSelectionSet(DocumentContext document, SelectionSetContext selectionSet, GraphQLObjectType? objectType, dynamic objectValue, Map<String, dynamic> variableValues, Map<String, dynamic> globalVariables, {List<List> lazy = const [], GraphQLObjectType? parentType}) → Future<Map<String, dynamic>>
Executes selectionSet against objectValue and answers the result map.
executeSubscriptionEvent(DocumentContext document, OperationDefinitionContext subscription, GraphQLSchema schema, dynamic initialValue, Map<String, dynamic> variableValues, Map<String, dynamic> globalVariables) → Future<Map<String, dynamic>>
Executes the subscription's selection set against one source event.
getDirectiveValue(String name, String argumentName, Directives holder, Map<String?, dynamic> variableValues) → dynamic
Reads the value a directive named name carries on holder.
getOperation(DocumentContext document, String? operationName) → OperationDefinitionContext
Picks the operation to execute out of document.
makeLazy(Map<String, dynamic> map) → List<List>
Collects the JsonPathArguments in map as paths still to be filled.
mapSourceToResponseEvent(Stream sourceStream, OperationDefinitionContext subscription, GraphQLSchema schema, DocumentContext document, dynamic initialValue, Map<String, dynamic> variableValues, Map<String, dynamic> globalVariables) → Stream<Map<String, dynamic>>
Maps each event of sourceStream to the response it produces.
mergeSelectionSets(List<SelectionContext> fields) → SelectionSetContext
Merges the sub-selections of fields into one selection set.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parseAndExecute(String text, {String? operationName, dynamic sourceUrl, Map<String, dynamic> variableValues = const {}, dynamic initialValue, Map<String, dynamic> globalVariables = const {}}) → Future
Parses text and executes it. The usual entry point.
resolveAbstractType(String? fieldName, GraphQLType type, dynamic result) → GraphQLObjectType
Decides which concrete object type result belongs to.
resolveFieldEventStream(GraphQLObjectType subscriptionType, dynamic rootValue, String? fieldName, Map<String, dynamic> argumentValues) → Future<Stream>
Calls the subscription field's resolver and normalises what it answers.
resolveFieldValue<T>(GraphQLObjectType objectType, T objectValue, String? fieldName, Map<String, dynamic> argumentValues) → Future<T?>
Reads one field off objectValue.
subscribe(DocumentContext document, OperationDefinitionContext subscription, GraphQLSchema schema, Map<String, dynamic> variableValues, Map<String, dynamic> globalVariables, dynamic initialValue) → Future<Stream<Map<String, dynamic>>>
Executes a subscription operation.
toString() → String
A string representation of this object.
inherited
validateDocument(DocumentContext document) → List<GraphQLExceptionError>
Checks document against the schema this executor was built on.

Operators

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