GraphQLClient class

Universal GraphQL Client with configurable caching and link system. modelled after the apollo-client.

The link is a Link over which GraphQL documents will be resolved into a Response. The cache is the GraphQLCache to use for caching results and optimistic updates.

The client automatically rebroadcasts watched queries when their underlying data changes in the cache. To skip the data comparison check, alwaysRebroadcast: true can be passed. NOTE: This flag was added ot accomodate the old default behavior. It is marked @experimental because it may be deprecated in the future.

Implemented types

Constructors

GraphQLClient({required Link link, required GraphQLCache cache, DefaultPolicies? defaultPolicies, bool alwaysRebroadcast = false})
Constructs a GraphQLClient given a Link and a Cache.

Properties

cache GraphQLCache
The initial Cache to use in the data store.
final
defaultPolicies DefaultPolicies
The default Policies to set for each client action
latefinal
hashCode int
The hash code for this object.
no setterinherited
The Link over which GraphQL documents will be resolved into a Response.
final
queryManager QueryManager
latefinal
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

copyWith({Link? link, GraphQLCache? cache, DefaultPolicies? defaultPolicies, bool? alwaysRebroadcast}) GraphQLClient
Create a copy of the client with the provided information.
fetchMore<TParsed>(FetchMoreOptions fetchMoreOptions, {required QueryOptions<TParsed> originalOptions, required QueryResult<TParsed> previousResult}) Future<QueryResult<TParsed>>
Fetch more results and then merge them with the given previousResult according to FetchMoreOptions.updateQuery.
mutate<TParsed>(MutationOptions<TParsed> options) Future<QueryResult<TParsed>>
This resolves a single mutation according to the MutationOptions specified and returns a Future which resolves with the QueryResult or throws an Exception.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
query<TParsed>(QueryOptions<TParsed> options) Future<QueryResult<TParsed>>
This resolves a single query according to the QueryOptions specified and returns a Future which resolves with the QueryResult or throws an Exception.
readFragment(FragmentRequest fragmentRequest, {bool optimistic = true}) Map<String, dynamic>?
pass through to cache.readFragment
override
readQuery(Request request, {bool optimistic = true}) Map<String, dynamic>?
pass through to cache.readQuery
override
resetStore({bool refetchQueries = true}) Future<List<QueryResult<Object?>?>>?
Resets the contents of the store with cache.store.reset() and then refetches of all queries unless refetchQueries is disabled
subscribe<TParsed>(SubscriptionOptions<TParsed> options) Stream<QueryResult<TParsed>>
This subscribes to a GraphQL subscription according to the options specified and returns a Stream which either emits received data or an error.
toString() String
A string representation of this object.
inherited
watchMutation<TParsed>(WatchQueryOptions<TParsed> options) ObservableQuery<TParsed>
watchMutation is the same as watchQuery, but with a different defaultPolicies that are more appropriate for mutations.
watchQuery<TParsed>(WatchQueryOptions<TParsed> options) ObservableQuery<TParsed>
This registers a query in the QueryManager and returns an ObservableQuery based on the provided WatchQueryOptions.
writeFragment(FragmentRequest fragmentRequest, {bool? broadcast = true, required Map<String, dynamic> data}) → void
pass through to cache.writeFragment and then rebroadcast any changes.
override
writeQuery(Request request, {required Map<String, dynamic> data, bool? broadcast = true}) → void
pass through to cache.writeQuery and then rebroadcast any changes.
override

Operators

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