Optional
getconsole.log(client.getMemoryInternals())
Logs output in the following JSON format:
{
limits: {
parser: 1000,
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: {
parser: 26,
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,
},
},
],
},
}
Optional
jwt_Optional
pathOptional
sslReadonly
typeThe 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.
Get all currently active ObservableQuery
objects, in a Map
keyed by
query ID strings.
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.
Optional
include: 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.
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.
Optional
includeStandby: booleanTries 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
.
Optional
optimistic: booleanSet 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 dataIdFromObject
use readFragment
.
Optional
optimistic: booleanSet to true
to allow readQuery
to return
optimistic results. Is false
by default.
Refetches 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.
This 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.
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 dataIdFromObject. 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 dataIdFromObject
then use writeFragment
.
This 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