graphql library
vendure's transport entrypoint — the GraphQL client library this package is compiled against.
The client itself is an implementation detail (repositories ride the
VendureDataSource port and never see it), but its types are on the
public surface: the innerClient named parameter of
GraphQLVendureDataSource accepts one, and buildDefaultClient /
buildSubscriptionClient return one. A consumer that injects a client
therefore has to name the same library vendure resolved — and two
same-named classes from different libraries are different types, so
guessing the transport package breaks the build.
Import it from here rather than from the transport package: which fork
vendure rides is vendure's decision to move (issue #13 moved it from
package:graphql/client.dart to package:graphql_plus/graphql_plus.dart
when the hardened fork was adopted), while this path stays.
Classes
- AuthLink
-
Simple header-based authentication link that adds headerKey:
getToken()to every request. - CancellableHttpLink
- An HTTP link that supports request cancellation.
-
CancellableOperation<
T> - Result wrapper that includes both the result future and a cancellation token.
- CancellationContextEntry
- Context entry that holds a CancellationToken.
- CancellationToken
- A token that can be used to cancel an in-flight GraphQL operation.
- ConnectionAck
- The server will send this acknowledgment message after receiving the init command from the client if the init was successful.
- ConnectionError
- The server will send this error message after receiving the init command from the client if the init was not successful.
- ConnectionKeepAlive
- The server will send this message to keep the connection alive
- Context
- A Context to be passed along with a Request.
- ContextEntry
- Entry in the Context.
- DedupeLink
- A Link to deduplicate Requests
- DefaultPolicies
- The default Policies to set for each client action.
- ErrorLink
- ErrorLink allows interception of GraphQL errors (using onGraphQLError) and LinkExceptions (using onException).
- ErrorLocation
- Location of a GraphQL error in the request document
- FetchMoreOptions
- options for fetchMore operations
- Fragment
- A fragment in a document, optionally defined by fragmentName
- FragmentRequest
- Cache access request of fragment with variables.
- GraphQLCache
-
Optimistic GraphQL Entity cache with
normalizeTypePolicysupport and configurable store. - GraphQLClient
-
Universal GraphQL Client with configurable caching and link system.
modelled after the
apollo-client. - GraphQLDataProxy
- A proxy to the normalized data living in our store.
- GraphQLError
- GraphQL Error returned if execution fails
- GraphQLProtocol
- ALL protocol supported by the library
- GraphQLSocketMessage
- Base type for representing a server-client subscription message.
- GraphQLWebSocketChannel
- HiveStore
- HttpLink
- A simple HttpLink implementation.
- HttpLinkHeaders
- HTTP link headers
- HttpLinkResponseContext
- HTTP link Response Context
- InitOperation
- After establishing a connection with the server, the client will send this message to tell the server that it is ready to begin sending new subscription queries.
- InMemoryStore
- Simplest possible Map-backed store
- JsonSerializable
- Link
-
DocumentNode-based GraphQL execution interface - MessageTypes
-
These messages represent the structures used for Client-server communication
in a GraphQL web-socket subscription. Each message is represented in a JSON
format where the data type is denoted by the
typefield. A list of constants used for identifying message types -
MultiSourceResult<
TParsed> -
MutationCallbackHandler<
TParsed> -
Handles execution of mutation
update,onCompleted, andonErrorcallbacks -
MutationOptions<
TParsed extends Object?> -
ObservableQuery<
TParsed> - An Observable/Stream-based API for both queries and mutations.
- Operation
- An operation in a document, optionally defined by operationName
- PassthroughLink
- PingMessage
- Policies
- Container for supplying fetch, error, and cacheReread policies.
- PongMessage
-
QueryCallbackHandler<
TParsed> - Handles execution of query callbacks
- QueryManager
-
QueryOptions<
TParsed extends Object?> - Query options.
- QueryPayload
- Represent the payload used during a Start query operation. The operationName should match one of the top level query definitions defined in the query provided. Additional variables can be provided and sent to the server for processing.
-
QueryResult<
TParsed extends Object?> - A single operation result
- Request
- Execution request of an operation with variables.
- RequestExtensionsThunk
- Exposes Request extensions
- RequestSerializer
- JSON Request serializer.
- Response
- Execution response
- ResponseExtensions
- Extensions returned with the response
- ResponseParser
- JSON Response parser
- SocketClient
- Wraps a standard web socket instance to marshal and un-marshal the server / client payloads into dart object representation.
- SocketClientConfig
- SocketSubProtocol
- All the protocol supported by the library
- StartOperation
- A message to tell the server to create a subscription. The contents of the query will be defined by the payload request. The id provided will be used to tag messages such that they can be identified for this subscription instance. id values should be unique and not be re-used during the lifetime of the server.
- StopOperation
- Tell the server to stop sending subscription data for a particular subscription instance. See StartOperation.
- Store
-
Raw key-value datastore API leveraged by the
Cache - SubscribeOperation
- SubscriptionComplete
- Server message to the client to indicate that no more data will be sent for a particular subscription instance.
- SubscriptionData
- Data sent from the server to the client with subscription data or error payload. The user should check the errors result before processing the data value. These error are from the query resolvers.
- SubscriptionError
- Errors sent from the server to the client if the subscription operation was not successful, usually due to GraphQL validation errors.
- SubscriptionListener
- SubscriptionNext
-
SubscriptionOptions<
TParsed extends Object?> - TerminateOperation
- The client sends this message to terminate the connection.
- UnknownData
- Not expected to be created. Indicates there are problems parsing the server response, or that new unsupported types have been added to the subscription implementation.
-
WatchQueryOptions<
TParsed extends Object?> - WebSocketLink
- A Universal Websocket Link implementation to support the websocket transport. It supports subscriptions, query and mutation operations as well.
Enums
- CacheRereadPolicy
-
CacheRereadPolicy determines whether and how cache data will be merged into
the final QueryResult
databefore it is returned. - ErrorPolicy
- ErrorPolicy determines the level of events for GraphQL Errors in the execution result. The options are:
- FetchPolicy
- FetchPolicy determines where the client may return a result from.
- PartialDataCachePolicy
- Determines how partial data should be handled when written to the cache
- QueryLifecycle
- Lifecycle states for ObservableQuery.lifecycle
- QueryResultSource
- The source of the result data contained
- SocketConnectionState
- ToggleConnectionState
Extensions
- FragmentDataValid on FragmentRequest
- Getters on QueryResultSource
- GraphQLGetter on WebSocketChannel
- OperationDataValid on Request
- OperationRequestHelper on Operation
- OperationTypeExtension on Operation
- WithType on Request
Properties
- gqlAsyncDeepEquals ↔ AsyncDeepEqualsFn
-
The async equality function used for comparing cached and new data
during asynchronous operations like rebroadcast checks.
getter/setter pair
- gqlDeepEquals ↔ DeepEqualsFn
-
The equality function used for comparing cached and new data
in synchronous contexts like operator overrides or custom logic.
getter/setter pair
Functions
-
coalesceErrors(
{List< GraphQLError> ? graphqlErrors, LinkException? linkException, List? raw, OperationException? exception}) → OperationException? -
(graphqlErrors?, exception?) => exception? -
gql(
String document) → DocumentNode -
Parse a GraphQL
documentinto aDocumentNode, automatically adding__typenames -
optimizedDeepEquals(
Object? a, Object? b) → bool -
Compare two json-like objects for equality
aandbmust be one of -
shouldRespondEagerlyFromCache(
FetchPolicy? fetchPolicy) → bool -
shouldStopAtCache(
FetchPolicy? fetchPolicy) → bool -
translateFailure(
Object failure, StackTrace trace) → LinkException -
willAlwaysExecuteOnNetwork(
FetchPolicy? policy) → bool
Typedefs
-
AsyncDeepEqualsFn
= Future<
bool> Function(dynamic a, dynamic b) -
ContextUpdater<
T> = T Function(T entry) - DeepEqualsFn = bool Function(dynamic a, dynamic b)
-
ErrorHandler
= Stream<
Response> ? Function(Request request, NextLink forward, Response response) - A handler of GraphQL errors.
-
ExceptionHandler
= Stream<
Response> ? Function(Request request, NextLink forward, LinkException exception) - A handler of Link Exceptions.
- GetInitPayload = FutureOr Function()
- GetRequestExtensions = dynamic Function(Request request)
-
HttpResponseDecoder
= FutureOr<
Map< Function(Response httpResponse)String, dynamic> ?> -
LinkFunction
= Stream<
Response> Function(Request request, [NextLink? forward]) - Link as a function
- LinkRouter = Link Function(Request request)
- A function which returns a Link based on contents Request
-
NextLink
= Stream<
Response> Function(Request request) -
Type of the
forwardfunction -
OnData<
TParsed> = FutureOr< void> Function(QueryResult<TParsed> ? result) - Side effect to register for execution when data is received
-
OnError
= FutureOr<
void> Function(OperationException? error) -
OnMutationCompleted
= FutureOr<
void> Function(Map<String, dynamic> ? data) -
OnMutationUpdate<
TParsed> = FutureOr< void> Function(GraphQLDataProxy cache, QueryResult<TParsed> ? result) -
OnQueryComplete
= FutureOr<
void> Function(Map<String, dynamic> ? data) -
OnQueryError
= FutureOr<
void> Function(OperationException? error) -
UpdateQuery
= Map<
String, dynamic> ? Function(Map<String, dynamic> ? previousResultData, Map<String, dynamic> ? fetchMoreResultData) - merge fetchMore result data with earlier result data
- VariableEncoder = Object Function(Object t)
-
WebSocketConnect
= FutureOr<
WebSocketChannel> Function(Uri uri, Iterable<String> ? protocols) -
A definition for functions that returns a connected
WebSocketChannel
Exceptions / Errors
- CacheMisconfigurationException
-
Failure occurring when the structure of data
does not match that of the request
operationdocument. - CacheMissException
- A failure to find a response from the cache.
- CancelledException
- Exception thrown when an operation is cancelled via a CancellationToken.
- ContextReadException
- Exception occurring when reading from the context
- ContextWriteException
- Exception occurring when writing to the context
- HttpLinkParserException
- Exception occurring when parsing fails.
- HttpLinkServerException
-
Exception occurring when network fails
or parsed response is missing both
dataanderrors. - LinkException
- A base class for exceptions thrown by links
- MismatchedDataStructureException
-
A failure due to a data structure mismatch between the data and the expected
structure based on the request
operationdocument. - NetworkException
- Exception occurring when there is a network-level error. This constructor is deprecated, use NetworkException.fromException instead.
- OperationException
- Container for both graphqlErrors returned from the server and any linkException that caused a failure.
- PartialDataException
- Exception occurring when structurally valid data cannot be resolved for an expected field.
- RequestFormatException
- Exception occurring when a terminating link tries to serialize the request
- ResponseFormatException
- Exception occurring when a terminating link tries to parse the response
- ServerException
-
Exception occurring when network fails
or parsed response is missing both
dataanderrors - UnexpectedResponseStructureException
-
Failure occurring when the structure of the parsedResponse
datadoes not match that of the requestoperationdocument. - UnknownException
- Exception occurring when an unhandled, non-link exception is thrown during execution