Basis for GraphQL execution layer to support Link and Client.
This package defines containers for a GraphQL document to be executed.
Parsing a GraphQL file will give you a
DocumentNode, which may contain
multiple operation definitions. In such case GraphQL requires you to
explicitly define the name of the operation to be executed. It can be
done by passing
operationName to the
Operation only carries the document and the operation name,
Request respresents the invocation of an operation. Alongside the operation,
it also carries the variables.
To execute a
Request you must pass it to some execution layer.
When some execution layer has processed the
Request it returns
possibly carrying a list of errors and/or data.
Response may carry additional context. Context is used
by the execution layer.
Context is a collection of context entries. A Context may only appear once per type.
// Create a context entry final entry = FooBarContextEntry( foo: 1, bar: 2, ); // Create a context with an entry final context = Context().withEntry(entry); // Update context somewhere in the execution layer final context2 = context.updateEntry( (FooBarContextEntry entry) => FooBarContextEntry( foo: entry.foo, bar: entry.bar * 2, ), ); // Retrieve context entry somewhere else in the execution layer final fooBarEntry = context.entry<FooBarContextEntry>();
Response also exposes helper methods to work with the context.
Features and bugs
Please file feature requests and bugs at the GitHub.