ReadonlydevtoolsOptional ExperimentalgetThis is not a stable API - it is used in development builds to expose information to the DevTools. Use at your own risk! For more details, see Memory Management
{
"limits": {
"canonicalStringify": 1000,
"print": 2000,
"documentTransform.cache": 2000,
"queryManager.getDocumentInfo": 2000,
"PersistedQueryLink.persistedQueryHashes": 2000,
"fragmentRegistry.transform": 2000,
"fragmentRegistry.lookup": 1000,
"fragmentRegistry.findFragmentSpreads": 4000,
"cache.fragmentQueryDocuments": 1000,
"removeTypenameFromVariables.getVariableDefinitions": 2000,
"inMemoryCache.maybeBroadcastWatch": 5000,
"inMemoryCache.executeSelectionSet": 10000,
"inMemoryCache.executeSubSelectedArray": 5000
},
"sizes": {
"canonicalStringify": 4,
"print": 14,
"addTypenameDocumentTransform": [
{
"cache": 14
}
],
"queryManager": {
"getDocumentInfo": 14,
"documentTransforms": [
{
"cache": 14
},
{
"cache": 14
}
]
},
"fragmentRegistry": {
"findFragmentSpreads": 34,
"lookup": 20,
"transform": 14
},
"cache": {
"fragmentQueryDocuments": 22
},
"inMemoryCache": {
"executeSelectionSet": 4345,
"executeSubSelectedArray": 1206,
"maybeBroadcastWatch": 32
},
"links": [
{
"PersistedQueryLink": {
"persistedQueryHashes": 14
}
},
{
"removeTypenameFromVariables": {
"getVariableDefinitions": 14
}
}
]
}
}
Refetches all of your active queries.
reFetchObservableQueries() is useful if you want to bring the client back to proper state in case of a network outage
It is important to remember that reFetchObservableQueries() will refetch any active
queries. This means that any components that might be mounted will execute
their queries again using your network interface. If you do not want to
re-execute any queries then you should make sure to stop watching any
active queries.
Takes optional parameter includeStandby which will include queries in standby-mode when refetching.
Note: cache-only queries are not refetched by this function.
The DocumentTransform used to modify GraphQL documents before a request
is made. If a custom DocumentTransform is not provided, this will be the
default document transform.
The configured LocalState instance used to enable the use of @client
fields.
Whether to prioritize cache values over network results when query or watchQuery is called.
This will essentially turn a "network-only" or "cache-and-network" fetchPolicy into a "cache-first" fetchPolicy,
but without influencing the fetchPolicy of the created ObservableQuery long-term.
This can e.g. be used to prioritize the cache during the first render after SSR.
Remove all data from the store. Unlike resetStore, clearStore will
not refetch any active queries.
Get all currently active ObservableQuery objects, in a Set.
An "active" query is one that has observers and a fetchPolicy other than
"standby" or "cache-only".
You can include all ObservableQuery objects (including the inactive ones)
by passing "all" instead of "active", or you can include just a subset of
active queries by passing an array of query names or DocumentNode objects.
Note: This method only returns queries that have active subscribers. Queries without subscribers are not tracked by the client.
Optionalinclude: RefetchQueriesIncludeThis resolves a single mutation according to the options specified and returns a
Promise which is either resolved with the resulting data or rejected with an
error. In some cases both data and errors might be undefined, for example
when errorPolicy is set to 'ignore'.
It takes options as an object with the following keys and values:
Allows callbacks to be registered that are executed when the store is
cleared. onClearStore returns an unsubscribe function that can be used
to remove registered callbacks.
Allows callbacks to be registered that are executed when the store is
reset. onResetStore returns an unsubscribe function that can be used
to remove registered callbacks.
This resolves a single query according to the options specified and
returns a Promise which is either resolved with the resulting data
or rejected with an error.
An object of type QueryOptions that allows us to
describe how this query should be treated e.g. whether it should hit the
server at all or just resolve from the cache, etc.
Tries to read some data from the store in the shape of the provided
GraphQL fragment without making a network request. This method will read a
GraphQL fragment from any arbitrary id that is currently cached, unlike
readQuery which will only read from the root query.
You must pass in a GraphQL document with a single fragment or a document
with multiple fragments that represent what you are reading. If you pass
in a document with multiple fragments then you must also specify a
fragmentName.
Tries to read some data from the store in the shape of the provided
GraphQL fragment without making a network request. This method will read a
GraphQL fragment from any arbitrary id that is currently cached, unlike
readQuery which will only read from the root query.
You must pass in a GraphQL document with a single fragment or a document
with multiple fragments that represent what you are reading. If you pass
in a document with multiple fragments then you must also specify a
fragmentName.
Set to true to allow readFragment to return
optimistic results. Is false by default.
Tries to read some data from the store in the shape of the provided
GraphQL query without making a network request. This method will start at
the root query. To start at a specific id returned by cache.identify
use readFragment.
Tries to read some data from the store in the shape of the provided
GraphQL query without making a network request. This method will start at
the root query. To start at a specific id returned by cache.identify
use readFragment.
Set to true to allow readQuery to return
optimistic results. Is false by default.
Refetches all of your active queries.
refetchObservableQueries() is useful if you want to bring the client back to proper state in case of a network outage
It is important to remember that refetchObservableQueries() will refetch any active
queries. This means that any components that might be mounted will execute
their queries again using your network interface. If you do not want to
re-execute any queries then you should make sure to stop watching any
active queries.
Takes optional parameter includeStandby which will include queries in standby-mode when refetching.
Note: cache-only queries are not refetched by this function.
OptionalincludeStandby: booleanRefetches specified active queries. Similar to "refetchObservableQueries()" but with a specific list of queries.
refetchQueries() is useful for use cases to imperatively refresh a selection of queries.
It is important to remember that refetchQueries() will refetch specified active
queries. This means that any components that might be mounted will execute
their queries again using your network interface. If you do not want to
re-execute any queries then you should make sure to stop watching any
active queries.
Resets your entire store by clearing out your cache and then re-executing all of your active queries. This makes it so that you may guarantee that there is no data left in your store from a time before you called this method.
resetStore() is useful when your user just logged out. You’ve removed the
user session, and you now want to make sure that any references to data you
might have fetched while the user session was active is gone.
It is important to remember that resetStore() will refetch any active
queries. This means that any components that might be mounted will execute
their queries again using your network interface. If you do not want to
re-execute any queries then you should make sure to stop watching any
active queries.
Replaces existing state in the cache (if any) with the values expressed by
serializedState.
Called when hydrating a cache (server side rendering, or offline storage), and also (potentially) during hot reloads.
Define a new ApolloLink (or link chain) that Apollo Client will use.
Call this method to terminate any active client processes, making it safe
to dispose of this ApolloClient instance.
This method performs aggressive cleanup to prevent memory leaks:
ObservableQuery instances by emitting a completed eventThis subscribes to a graphql subscription according to the options specified and returns an
Observable which either emits received data or an error.
Watches the cache store of the fragment according to the options specified
and returns an Observable. We can subscribe to this
Observable and receive updated results through an
observer when the cache store changes.
You must pass in a GraphQL document with a single fragment or a document
with multiple fragments that represent what you are reading. If you pass
in a document with multiple fragments then you must also specify a
fragmentName.
An object of type WatchFragmentOptions that allows
the cache to identify the fragment and optionally specify whether to react
to optimistic updates.
Watches the cache store of the fragment according to the options specified
and returns an Observable. We can subscribe to this
Observable and receive updated results through an
observer when the cache store changes.
You must pass in a GraphQL document with a single fragment or a document
with multiple fragments that represent what you are reading. If you pass
in a document with multiple fragments then you must also specify a
fragmentName.
An object of type WatchFragmentOptions that allows
the cache to identify the fragment and optionally specify whether to react
to optimistic updates.
Watches the cache store of the fragment according to the options specified
and returns an Observable. We can subscribe to this
Observable and receive updated results through an
observer when the cache store changes.
You must pass in a GraphQL document with a single fragment or a document
with multiple fragments that represent what you are reading. If you pass
in a document with multiple fragments then you must also specify a
fragmentName.
An object of type WatchFragmentOptions that allows
the cache to identify the fragment and optionally specify whether to react
to optimistic updates.
Watches the cache store of the fragment according to the options specified
and returns an Observable. We can subscribe to this
Observable and receive updated results through an
observer when the cache store changes.
You must pass in a GraphQL document with a single fragment or a document
with multiple fragments that represent what you are reading. If you pass
in a document with multiple fragments then you must also specify a
fragmentName.
An object of type WatchFragmentOptions that allows
the cache to identify the fragment and optionally specify whether to react
to optimistic updates.
Watches the cache store of the fragment according to the options specified
and returns an Observable. We can subscribe to this
Observable and receive updated results through an
observer when the cache store changes.
You must pass in a GraphQL document with a single fragment or a document
with multiple fragments that represent what you are reading. If you pass
in a document with multiple fragments then you must also specify a
fragmentName.
An object of type WatchFragmentOptions that allows
the cache to identify the fragment and optionally specify whether to react
to optimistic updates.
Watches the cache store of the fragment according to the options specified
and returns an Observable. We can subscribe to this
Observable and receive updated results through an
observer when the cache store changes.
You must pass in a GraphQL document with a single fragment or a document
with multiple fragments that represent what you are reading. If you pass
in a document with multiple fragments then you must also specify a
fragmentName.
An object of type WatchFragmentOptions that allows
the cache to identify the fragment and optionally specify whether to react
to optimistic updates.
This watches the cache store of the query according to the options specified and
returns an ObservableQuery. We can subscribe to this ObservableQuery and
receive updated results through an observer when the cache store changes.
Note that this method is not an implementation of GraphQL subscriptions. Rather, it uses Apollo's store in order to reactively deliver updates to your query results.
For example, suppose you call watchQuery on a GraphQL query that fetches a person's
first and last name and this person has a particular object identifier, provided by
cache.identify. Later, a different query fetches that same person's
first and last name and the first name has now changed. Then, any observers associated
with the results of the first query will be updated with a new result object.
Note that if the cache does not change, the subscriber will not be notified.
See here for a description of store reactivity.
Writes some data in the shape of the provided GraphQL fragment directly to
the store. This method will write to a GraphQL fragment from any arbitrary
id that is currently cached, unlike writeQuery which will only write
from the root query.
You must pass in a GraphQL document with a single fragment or a document
with multiple fragments that represent what you are writing. If you pass
in a document with multiple fragments then you must also specify a
fragmentName.
Writes some data in the shape of the provided GraphQL query directly to
the store. This method will start at the root query. To start at a
specific id returned by cache.identify then use writeFragment.
This is the primary Apollo Client class. It is used to send GraphQL documents (i.e. queries and mutations) to a GraphQL spec-compliant server over an
ApolloLinkinstance, receive results from the server and cache the results in a store. It also delivers updates to GraphQL queries throughObservableinstances.