gql_exec

Creator: coderz1093

Last updated:

Add to Cart

Description:

gql exec

Basis for GraphQL execution layer to support Link and Client.
This package defines containers for a GraphQL document to be executed.
Used by package:gql_link.
Operation #
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 constructor.
Request #
While 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.
Response #
When some execution layer has processed the Request it returns Response
possibly carrying a list of errors and/or data.
Context #
Both Request and 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>();
copied to clipboard
Request and Response also exposes helper methods to work with the context.
Features and bugs #
Please file feature requests and bugs at the GitHub.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.