@apollo/client
InMemoryCache
will no longer merge the fields of written objects unless the objects are known to have the same identity, and the values of fields with the same name will not be recursively merged unless a custom merge
function is defined by a field policy for that field, within a type policy associated with the __typename
of the parent object.graphql-anywhere
since it’s no longer used by Apollo Client.apollo-boost
since Apollo Client 3.0 provides a boost like getting started experience out of the box.queryManager
property of ApolloClient
instances is now marked as private
, paving the way for a more aggressive redesign of its API.FragmentMatcher
, HeuristicFragmentMatcher
, and IntrospectionFragmentMatcher
have all been removed. We now recommend using InMemoryCache
’s possibleTypes
option instead. For more information see the Defining [possibleTypes](https://www.apollographql.com/docs/react/v3.0-beta/data/fragments/#defining-possibletypes-manually)
manually section of the docs.ApolloClient
is now only available as a named export. The default ApolloClient
export has been removed.QueryOptions
, MutationOptions
, and SubscriptionOptions
React Apollo interfaces have been renamed to QueryDataOptions
, MutationDataOptions
, and SubscriptionDataOptions
(to avoid conflicting with similarly named and exported Apollo Client interfaces).apollo-cache
, apollo-cache-inmemory
, or apollo-utilities
, they may no longer be available from @apollo/client
.fixPolyfills.ts
, except when bundling for React Native. If you have trouble with Map
or Set
operations due to frozen key objects in React Native, either update React Native to version 0.59.0 (or 0.61.x, if possible) or investigate why fixPolyfills.native.js
is not included in your bundle.@client
fields to be passed into the link
chain if resolvers
were not set in the constructor. This allowed @client
fields to be passed into Links like apollo-link-state
. Apollo Client 3 enforces that @client
fields are local only, meaning they are no longer passed into the link
chain, under any circumstances.InMemoryCache
now throws when data with missing or undefined query fields is written into the cache, rather than just warning in development.client|cache.writeData
have been fully removed. writeData
usage is one of the easiest ways to turn faulty assumptions about how the cache represents data internally, into cache inconsistency and corruption. client|cache.writeQuery
, client|cache.writeFragment
, and/or cache.modify
can be used to update the cache.ObservableQuery
consumers, but will instead log more helpful errors about which cache fields were missing.ApolloError
’s thrown by Apollo Client no longer prefix error messages with GraphQL error:
or Network error:
. To differentiate between GraphQL/network errors, refer to ApolloError
’s public graphQLErrors
and networkError
properties.@live
directive has been removed, but might be restored in the future if a more thorough implementation is proposed.QueryManager
to make better use of observables and enforce fetchPolicy
more reliably.InMemoryCache
now supports tracing garbage collection and eviction. Note that the signature of the evict
method has been simplified in a potentially backwards-incompatible way.cache.evict
method now requires Cache.EvictOptions
, though it previously supported positional arguments as well.cache.evict
, cache.writeQuery
, and cache.writeFragment
, can now be called with a named options object, which supports a broadcast: boolean
property that can be used to silence the broadcast, for situations where you want to update the cache multiple times without triggering a broadcast each time.InMemoryCache
now console.warn
s in development whenever non-normalized data is dangerously overwritten, with helpful links to documentation about normalization and custom merge
functions.@apollo/react-hooks
package have been merged into @apollo/client
, enabling the following all-in-one import
:import { ApolloClient, ApolloProvider, useQuery } from '@apollo/client';
@apollo/client
. Functionality that was previously available through the apollo-link
, apollo-link-http-common
and apollo-link-http
packages is now directly available from @apollo/client
(e.g. import { HttpLink } from '@apollo/client'
). The ApolloClient
constructor has also been updated to accept new uri
, headers
and credentials
options. If uri
is specified, Apollo Client will take care of creating the necessary HttpLink
behind the scenes.gql
template tag should now be imported from the @apollo/client
package, rather than the graphql-tag
package. Although the graphql-tag
package still works for now, future versions of @apollo/client
may change the implementation details of gql
without a major version bump.@apollo/client/core
can be used to import the Apollo Client core, which includes everything the main @apollo/client
package does, except for all React related functionality.@apollo/client/cache
can be used to import the Apollo Client cache without importing other parts of the Apollo Client codebase.===
) results much more often than before.InMemoryCache
now has a method called modify
which can be used to update the value of a specific field within a specific entity object:cache.modify({
id: cache.identify(post),
fields: {
comments(comments: Reference[], { readField }) {
return comments.filter(comment => idToRemove !== readField("id", comment));
},
},
});
cache.evict
method is now implemented in terms of cache.modify
.InMemoryCache
provides a new API for storing client state that can be updated from anywhere:const v = cache.makeVar(123)
console.log(v()) // 123
console.log(v(v() + 1)) // 124
console.log(v()) // 124
v("asdf") // TS type error
cache.readQuery
and cache.writeQuery
methods now accept an options.id
string, which eliminates most use cases for cache.readFragment
and cache.writeFragment
, and skips the implicit conversion of fragment documents to query documents performed by cache.{read,write}Fragment
.ApolloClient#initQueryManager
QueryManager#startQuery
ObservableQuery#currentResult
cache.identify(entity)
for easily computing entity ID strings.cache.evict(id, fieldName)
.InMemoryCache#evict
remove data from all EntityStore
layers.previousResult
in InMemoryCache
.read
functions can read from neighboring fields using the readField(fieldName)
helper, and may also read fields from other entities by calling readField(fieldName, objectOrReference)
.apollo-utilities
package are now only available by importing from @apollo/client/utilities
.graphql-tag
public exports are re-exported.prettier
. The Apollo Client team has decided to no longer automatically enforce code formatting across the codebase. In most cases existing code styles should be followed as much as possible, but this is not a hard and fast rule.ApolloContext
plays nicely with IE11 when storing the shared context.modify
and identify
to the mutate update
function.gc
implementation to ApolloCache
.graphql@15
.ApolloLink
(or link chain) after new ApolloClient()
has been called, using the ApolloClient#setLink
method.#apollo #developer