Releases: apollographql/apollo-client
3.5.x
Apollo Client 3.5.5 (2021-11-23)
Bug Fixes
- Remove
printer: Printer
positional parameter from publicly-exportedselectHttpOptionsAndBody
function, whose addition in #8699 was a breaking change (starting in Apollo Client 3.5.0) for direct consumers ofselectHttpOptionsAndBody
.
@benjamn in #9103
Apollo Client 3.5.4 (2021-11-19)
Notices
-
[Relevant if you use Apollo Client with React Native] Since Apollo Client v3.5.0, CommonJS bundles provided by
@apollo/client
use a.cjs
file extension rather than.cjs.js
, so Node.js won't interpret them as ECMAScript modules. While this change should be an implementation detail, it may cause problems for the Metro bundler used by React Native, whoseresolver.sourceExts
configuration does not include thecjs
extension by default.As a workaround until this issue is resolved, you can configure Metro to understand the
.cjs
file extension by creating ametro.config.js
file in the root of your React Native project:const { getDefaultConfig } = require("metro-config"); const { resolver: defaultResolver } = getDefaultConfig.getDefaultValues(); exports.resolver = { ...defaultResolver, sourceExts: [ ...defaultResolver.sourceExts, "cjs", ], };
Improvements
-
Restore the ability to pass
onError()
andonCompleted()
to the mutation execution function.
@brainkim in #9076 -
Work around webpack 5 errors of the form
The request 'ts-invariant/process' failed to resolve only because it was resolved as fully specified
by ensuring
import ... from 'ts-invariant/process'
is internally written toimport ... from 'ts-invariant/process/index.js'
.
@benjamn in #9083
Apollo Client 3.5.3 (2021-11-17)
-
Avoid rewriting non-relative imported module specifiers in
config/rewriteModuleIds.ts
script, thereby allowing bundlers to resolve those imports as they see fit.
@benjamn in #9073 -
Ensure only current file is matched when running VSCode debugger.
@eps1lon in #9050
Apollo Client 3.5.2 (2021-11-10)
- Fix useMutation execute function returning non-identical execution functions when passing similar options.
@brainkim in #9093
Apollo Client 3.5.1 (2021-11-09)
Apollo Client 3.5.0 (2021-11-08)
Improvements
-
Add
updateQuery
andupdateFragment
methods toApolloCache
, simplifying commonreadQuery
/writeQuery
cache update patterns.
@wassim-k in #8382 -
Field directives and their arguments can now be included along with field argument names when using field policy
keyArgs: [...]
notation. For example, if you have aQuery.feed
field that takes an argument calledtype
and uses a@connection(key:...)
directive to keepfeed
data from different queries separate within the cache, you might configure both using the followingInMemoryCache
field policy:new InMemoryCache({ typePolicies: { Query: { fields: { feed: { keyArgs: ["type", "@connection", ["key"]], }, }, }, }, })
-
Report single
MissingFieldError
instead of a potentially very largeMissingFieldError[]
array for incomplete cache reads, improving performance and memory usage.
@benjamn in #8734 -
When writing results into
InMemoryCache
, each written object is now identified usingpolicies.identify
after traversing the fields of the object (rather than before), simplifying identification and reducing duplicate work. If you have customkeyFields
functions, they still receive the raw result object as their first parameter, but theKeyFieldsContext
parameter now providescontext.storeObject
(theStoreObject
just processed byprocessSelectionSet
) andcontext.readField
(a helper function for reading fields fromcontext.storeObject
and anyReference
s it might contain, similar toreadField
forread
,merge
, andcache.modify
functions).
@benjamn in #8996 -
Ensure
cache.identify
never throws when primary key fields are missing, and include the source object in the error message whenkeyFields
processing fails.
@benjamn in #8679 -
The
HttpLink
constructor now accepts an optionalprint
function that can be used to customize how GraphQLDocumentNode
objects are transformed back into strings before they are sent over the network.
@sarahgp in #8699 -
Make
@apollo/client/testing
a fully-fledged, independent entry point, instead of re-exporting@apollo/client/utilities/testing
(which was never an entry point and no longer exists).
@benjamn in #8769 -
A new nested entry point called
@apollo/client/testing/core
has been created. Importing from this entry point instead of@apollo/client/testing
excludes any React-related dependencies.
@wassim-k in #8687 -
Make
cache.batch
return the result of calling theoptions.update
function.
@benjamn in #8696 -
The
NetworkError
andErrorResponse
types have been changed to align more closely.
@korywka in #8424 -
Update
zen-observable-ts
to eliminate transitive dependency on@types/zen-observable
.
@benjamn in #8695
React Refactoring
Improvements (due to @brainkim in #8875):
- The
useLazyQuery
function now returns a promise with the result. - The
useMutation
result now exposes a method which can be reset.
Bug Fixes (due to @brainkim in #8596):
- The
useQuery
anduseLazyQuery
hooks will now haveObservableQuery
methods defined consistently. - Calling
useLazyQuery
methods likestartPolling
will start the query. - Calling the
useLazyQuery
execution function will now behave more likerefetch
.previousData
will be preserved. standby
fetchPolicies will now act likeskip: true
more consistently.- Calling
refetch
on a skipped query will have no effect (issue #8270). - Prevent
onError
andonCompleted
functions from firing continuously, and improving their polling behavior.
3.4.0
Apollo Client 3.4.0
New documentation
- Refetching queries with
client.refetchQueries
.
@StephenBarlow and @benjamn in #8265
Improvements
-
InMemoryCache
now guarantees that any two result objects returned by the cache (fromreadQuery
,readFragment
, etc.) will be referentially equal (===
) if they are deeply equal. Previously,===
equality was often achievable for results for the same query, on a best-effort basis. Now, equivalent result objects will be automatically shared among the result trees of completely different queries. This guarantee is important for taking full advantage of optimistic updates that correctly guess the final data, and for "pure" UI components that can skip re-rendering when their input data are unchanged.
@benjamn in #7439 -
Mutations now accept an optional callback function called
onQueryUpdated
, which will be passed theObservableQuery
andCache.DiffResult
objects for any queries invalidated by cache writes performed by the mutation's finalupdate
function. UsingonQueryUpdated
, you can override the defaultFetchPolicy
of the query, by (for example) callingObservableQuery
methods likerefetch
to force a network request. This automatic detection of invalidated queries provides an alternative to manually enumerating queries using therefetchQueries
mutation option. Also, if you return aPromise
fromonQueryUpdated
, the mutation will automatically await thatPromise
, rendering theawaitRefetchQueries
option unnecessary.
@benjamn in #7827 -
Support
client.refetchQueries
as an imperative way to refetch queries, without having to passoptions.refetchQueries
toclient.mutate
.
@dannycochran in #7431 -
Improve standalone
client.refetchQueries
method to support automatic detection of queries needing to be refetched.
@benjamn in #8000 -
Fix remaining barriers to loading
@apollo/client/core
as native ECMAScript modules from a CDN like esm.run. Importing@apollo/client
from a CDN will become possible once we move all React-related dependencies into@apollo/client/react
in Apollo Client 4.
@benjamn in #8266 -
InMemoryCache
supports a new method calledbatch
, which is similar toperformTransaction
but takes named options rather than positional parameters. One of these named options is anonDirty(watch, diff)
callback, which can be used to determine which watched queries were invalidated by thebatch
operation.
@benjamn in #7819 -
Allow
merge: true
field policy to mergeReference
objects with non-normalized objects, and vice-versa.
@benjamn in #7778 -
Allow identical subscriptions to be deduplicated by default, like queries.
@jkossis in #6910 -
Always use
POST
request when falling back to sending full query with@apollo/client/link/persisted-queries
.
@rieset in #7456 -
The
FetchMoreQueryOptions
type now takes two instead of three type parameters (<TVariables, TData>
), thanks to usingPartial<TVariables>
instead ofK extends typeof TVariables
andPick<TVariables, K>
.
@ArnaudBarre in #7476 -
Pass
variables
andcontext
to a mutation'supdate
function. Note: The type of theupdate
function is now namedMutationUpdaterFunction
rather thanMutationUpdaterFn
, since the older type was broken beyond repair. If you are usingMutationUpdaterFn
in your own code, please useMutationUpdaterFunction
instead.
@jcreighton in #7902 -
A
resultCacheMaxSize
option may be passed to theInMemoryCache
constructor to limit the number of result objects that will be retained in memory (to speed up repeated reads), and callingcache.reset()
now releases all such memory.
@SofianHn in #8701 -
Fully remove result cache entries from LRU dependency system when the corresponding entities are removed from
InMemoryCache
by eviction, or by any other means.
@sofianhn and @benjamn in #8147 -
Add expected/received
variables
toNo more mocked responses...
error messages generated byMockLink
.
@markneub in #8340 -
The
InMemoryCache
version of thecache.gc
method now supports additional options for removing non-essential (recomputable) result caching data.
@benjamn in #8421 -
Suppress noisy
Missing cache result fields...
warnings by default unlesssetLogVerbosity("debug")
called.
@benjamn in #8489 -
Improve interaction between React hooks and React Fast Refresh in development.
@andreialecu in #7952
Potentially disruptive changes
-
To avoid retaining sensitive information from mutation root field arguments, Apollo Client v3.4 automatically clears any
ROOT_MUTATION
fields from the cache after each mutation finishes. If you need this information to remain in the cache, you can prevent the removal by passing thekeepRootFields: true
option toclient.mutate
.ROOT_MUTATION
result data are also passed to the mutationupdate
function, so we recommend obtaining the results that way, rather than usingkeepRootFields: true
, if possible.
@benjamn in #8280 -
Internally, Apollo Client now controls the execution of development-only code using the
__DEV__
global variable, rather thanprocess.env.NODE_ENV
. While this change should not cause any visible differences in behavior, it will increase your minified+gzip bundle size by more than 3.5kB, unless you configure your minifier to replace__DEV__
with atrue
orfalse
constant, the same way you already replaceprocess.env.NODE_ENV
with a string literal like"development"
or"production"
. For an example of configuring a Create React App project without ejecting, see this pull request for our React Apollo reproduction template.
@benjamn in #8347 -
Internally, Apollo Client now uses namespace syntax (e.g.
import * as React from "react"
) for imports whose types are re-exported (and thus may appear in.d.ts
files). This change should remove any need to configureesModuleInterop
orallowSyntheticDefaultImports
intsconfig.json
, but might require updating bundler configurations that specify named exports of thereact
andprop-types
packages, to include exports likecreateContext
andcreateElement
(example).
@devrelm in #7742 -
Respect
no-cache
fetch policy (by not reading anydata
from the cache) forloading: true
results triggered bynotifyOnNetworkStatusChange: true
.
@jcreighton in #7761 -
The TypeScript return types of the
getLastResult
andgetLastError
methods ofObservableQuery
now correctly include the possibility of returningundefined
. If you happen to be calling either of these methods directly, you may need to adjust how the calling code handles the methods' possibly-undefined
results.
@benjamn in #8394 -
Log non-fatal
invariant.error
message when fields are missing from result objects written intoInMemoryCache
, rather than throwing an exception. While this change relaxes an exception to be merely an error message, which is usually a backwards-compatible change, the error messages are logged in more cases now than the exception was previously thrown, and those new error messages may be worth investigating to discover potential problems in your application. The errors ...
3.3.0
Apollo Client 3.3.0
Bug Fixes
-
Update
@wry/equality
to consider undefined properties equivalent to missing properties.
@benjamn in #7108 -
Prevent memory leaks involving unused
onBroadcast
function closure created inApolloClient
constructor.
@kamilkisiela in #7161 -
Provide default empty cache object for root IDs like
ROOT_QUERY
, to avoid differences in behavior before/afterROOT_QUERY
data has been written intoInMemoryCache
.
@benjamn in #7100 -
Cancel
queryInfo.notifyTimeout
inQueryInfo#markResult
to prevent unnecessary network requests when using aFetchPolicy
ofcache-and-network
ornetwork-only
in a React component with multipleuseQuery
calls.
@benjamn in #7347
Potentially breaking changes
-
Ensure
cache.readQuery
andcache.readFragment
always returnTData | null
, instead of throwingMissingFieldError
exceptions when missing fields are encountered.
@benjamn in #7098Since this change converts prior exceptions to
null
returns, and sincenull
was already a possible return value according to theTData | null
return type, we are confident this change will be backwards compatible (as long asnull
was properly handled before). -
HttpLink
will now automatically strip any unusedvariables
before sending queries to the GraphQL server, since those queries are very likely to fail validation, according to the All Variables Used rule in the GraphQL specification. If you depend on the preservation of unused variables, you can restore the previous behavior by passingincludeUnusedVariables: true
to theHttpLink
constructor (which is typically passed asoptions.link
to theApolloClient
constructor).
@benjamn in #7127 -
Ensure
MockLink
(used byMockedProvider
) returns mock configuration errors (e.g.No more mocked responses for the query ...
) through the Link'sObservable
, instead of throwing them. These errors are now available through theerror
property of a result.
@hwillson in #7110Returning mock configuration errors through the Link's
Observable
was the default behavior in Apollo Client 2.x. We changed it for 3, but the change has been problematic for those looking to migrate from 2.x to 3. We've decided to change this back with the understanding that not many people want or are relying onMockLink
's throwing exception approach. If you want to change this functionality, you can define custom error handling throughMockLink.setOnError
. -
Unsubscribing the last observer from an
ObservableQuery
will once again unsubscribe from the underlying networkObservable
in all cases, as in Apollo Client 2.x, allowing network requests to be cancelled by unsubscribing.
@javier-garcia-meteologica in #7165 and #7170. -
The independent
QueryBaseOptions
andModifiableWatchQueryOptions
interface supertypes have been eliminated, and their fields are now defined byQueryOptions
.
@DCtheTall in #7136 -
Internally, Apollo Client now avoids nested imports from the
graphql
package, importing everything from the top-level package instead. For example,import { visit } from "graphql/language/visitor"
is now just
import { visit } from "graphql"
Since the
graphql
package uses.mjs
modules, your bundler may need to be configured to recognize.mjs
files as ECMAScript modules rather than CommonJS modules.
@benjamn in #7185
Improvements
-
Support inheritance of type and field policies, according to
possibleTypes
.
@benjamn in #7065 -
Allow configuring custom
merge
functions, including themerge: true
andmerge: false
shorthands, in type policies as well as field policies.
@benjamn in #7070 -
The verbosity of Apollo Client console messages can be globally adjusted using the
setLogVerbosity
function:import { setLogVerbosity } from "@apollo/client"; setLogVerbosity("log"); // display all messages setLogVerbosity("warn"); // display only warnings and errors (default) setLogVerbosity("error"); // display only errors setLogVerbosity("silent"); // hide all console messages
Remember that all logs, warnings, and errors are hidden in production.
@benjamn in #7226 -
Modifying
InMemoryCache
fields that havekeyArgs
configured will now invalidate only the field value with matching key arguments, rather than invalidating all field values that share the same field name. IfkeyArgs
has not been configured, the cache must err on the side of invalidating by field name, as before.
@benjamn in #7351 -
Shallow-merge
options.variables
when combining existing or default options with newly-provided options, so new variables do not completely overwrite existing variables.
@amannn in #6927 -
Avoid displaying
Cache data may be lost...
warnings for scalar field values that happen to be objects, such as JSON data.
@benjamn in #7075 -
In addition to the
result.data
property,useQuery
anduseLazyQuery
will now provide aresult.previousData
property, which can be useful when a network request is pending andresult.data
is undefined, sinceresult.previousData
can be rendered instead of rendering an empty/loading state.
@hwillson in #7082 -
Passing
validate: true
to theSchemaLink
constructor will enable validation of incoming queries against the local schema before execution, returning validation errors inresult.errors
, just like a non-local GraphQL endpoint typically would.
@amannn in #7094 -
Allow optional arguments in
keyArgs: [...]
arrays forInMemoryCache
field policies.
@benjamn in #7109 -
Avoid registering
QueryPromise
whenskip
istrue
during server-side rendering.
@izumin5210 in #7310 -
ApolloCache
objects (includingInMemoryCache
) may now be associated with or disassociated from individual reactive variables by callingreactiveVar.attachCache(cache)
and/orreactiveVar.forgetCache(cache)
.
@benjamn in #7350
3.2.0
Apollo Client 3.2.0
Bug Fixes
-
Use
options.nextFetchPolicy
internally to restore originalFetchPolicy
after polling withfetchPolicy: "network-only"
, so that polling does not interfere with normal query watching.
@benjamn in #6893 -
Initialize
ObservableQuery
inupdateObservableQuery
even ifskip
istrue
.
@mu29 in #6999 -
Prevent full reobservation of queries affected by optimistic mutation updates, while still delivering results from the cache.
@benjamn in #6854
Improvements
-
In TypeScript, all APIs that take
DocumentNode
parameters now may alternatively takeTypeDocumentNode<Data, Variables>
. This type has the same JavaScript representation but allows the APIs to infer the data and variable types instead of requiring you to specify types explicitly at the call site.
@dotansimha in #6720 -
Bring back an improved form of heuristic fragment matching, by allowing
possibleTypes
to specify subtype regular expression strings, which count as matches if the written result object has all the fields expected for the fragment.
@benjamn in #6901 -
Allow
options.nextFetchPolicy
to be a function that takes the currentFetchPolicy
and returns a new (or the same)FetchPolicy
, makingnextFetchPolicy
more suitable for global use indefaultOptions.watchQuery
.
@benjamn in #6893 -
Implement
useReactiveVar
hook for consuming reactive variables in React components.
@benjamn in #6867 -
Move
apollo-link-persisted-queries
implementation to@apollo/client/link/persisted-queries
. Try running our automated imports transform to handle this conversion, if you're usingapollo-link-persisted-queries
.
@hwillson in #6837 -
Disable feud-stopping logic after any
cache.evict
orcache.modify
operation.
@benjamn in
#6817 and
#6898 -
Throw if
writeFragment
cannot identifyoptions.data
when nooptions.id
provided.
@jcreighton in #6859 -
Provide
options.storage
object tocache.modify
functions, as provided toread
andmerge
functions.
@benjamn in #6991 -
Allow
cache.modify
functions to returndetails.INVALIDATE
(similar todetails.DELETE
) to invalidate the current field, causing affected queries to rerun, even if the field's value is unchanged.
@benjamn in #6991 -
Support non-default
ErrorPolicy
values (that is,"ignore"
and"all"
, in addition to the default value"none"
) for mutations and subscriptions, like we do for queries.
@benjamn in #7003 -
Remove invariant forbidding a
FetchPolicy
ofcache-only
inObservableQuery#refetch
.
@benjamn in ccb0a79a, fixing #6702
Apollo Client 3.1.5
Bug Fixes
Improvements
Apollo Client 3.1.4
Bug Fixes
-
Restrict root object identification to
ROOT_QUERY
(the ID corresponding to the rootQuery
object), allowingMutation
andSubscription
as user-defined types.
@benjamn in #6914 -
Prevent crash when
pageInfo
and emptyedges
are received byrelayStylePagination
.
@fracmak in #6918
Apollo Client 3.1.3
Bug Fixes
- Consider only
result.data
(rather than all properties ofresult
) when settling cache feuds.
@danReynolds in #6777
Improvements
- Provide jscodeshift transform for automatically converting Apollo Client 2.x
import
declarations to use Apollo Client 3.x packages. Instructions.
@dminkovsky and @jcreighton in #6486
Apollo Client 3.1.2
Bug Fixes
Improvements
Apollo Client 3.1.1
Bug Fixes
3.1.0
Apollo Client 3.1.0
Bug Fixes
-
Rework interdependencies between
@apollo/client/*
entry points, so that CommonJS and ESM modules are supported equally well, without any duplication of shared code.
@benjamn in #6656 and #6657 -
Tolerate
!==
callback functions (likeonCompleted
andonError
) inuseQuery
options, since those functions are almost always freshly evaluated each timeuseQuery
is called.
@hwillson and @benjamn in #6588 -
Respect
context.queryDeduplication
if provided, and otherwise fall back toclient.deduplication
(as before).
@igaloly in #6261 and @Kujawadl in #6526 -
Refactor
ObservableQuery#getCurrentResult
to reenable immediate delivery of warm cache results. As part of this refactoring, theApolloCurrentQueryResult
type was eliminated in favor ofApolloQueryResult
.
@benjamn in #6710 -
Avoid clobbering
defaultOptions
withundefined
values.
@benjamn in #6715
Improvements
-
Apollo Client will no longer modify
options.fetchPolicy
unless you passoptions.nextFetchPolicy
to request an explicit change inFetchPolicy
after the current request. Although this is technically a breaking change,options.nextFieldPolicy
makes it easy to restore the old behavior (by passingcache-first
).
@benjamn in #6712, reverting #6353 -
Errors of the form
Invariant Violation: 42
thrown in production can now be looked up much more easily, by consulting the auto-generated@apollo/client/invariantErrorCodes.js
file specific to your@apollo/client
version.
@benjamn in #6665 -
Make the
client
field of theMutationResult
type non-optional, since it is always provided.
@glasser in #6617 -
Allow passing an asynchronous
options.renderFunction
togetMarkupFromTree
.
@richardscarrott in #6576 -
Ergonomic improvements for
merge
andkeyArgs
functions in cache field policies.
@benjamn in #6714
Apollo Client 3.0.2
Bug Fixes
- Avoid duplicating
graphql/execution/execute
dependency in CommonJS bundle for@apollo/client/link/schema
, fixinginstanceof
errors reported in #6621 and #6614.
@benjamn in #6624
Apollo Client 3.0.1
Bug Fixes
3.0.0
Apollo Client 3.0.0
Improvements
⚠️ Note: As of 3.0.0, Apollo Client uses a new package name:@apollo/client
ApolloClient
-
[BREAKING]
ApolloClient
is now only available as a named export. The defaultApolloClient
export has been removed.
@hwillson in #5425 -
[BREAKING] The
queryManager
property ofApolloClient
instances is now marked asprivate
, paving the way for a more aggressive redesign of its API. -
[BREAKING] Apollo Client will no longer deliver "stale" results to
ObservableQuery
consumers, but will instead log more helpful errors about which cache fields were missing.
@benjamn in #6058 -
[BREAKING]
ApolloError
's thrown by Apollo Client no longer prefix error messages withGraphQL error:
orNetwork error:
. To differentiate between GraphQL/network errors, refer toApolloError
's publicgraphQLErrors
andnetworkError
properties.
@lorensr in #3892 -
[BREAKING] Support for the
@live
directive has been removed, but might be restored in the future if a more thorough implementation is proposed.
@benjamn in #6221 -
[BREAKING] Apollo Client 2.x allowed
@client
fields to be passed into thelink
chain ifresolvers
were not set in the constructor. This allowed@client
fields to be passed into Links likeapollo-link-state
. Apollo Client 3 enforces that@client
fields are local only, meaning they are no longer passed into thelink
chain, under any circumstances.
@hwillson in #5982 -
[BREAKING?] Refactor
QueryManager
to make better use of observables and enforcefetchPolicy
more reliably.
@benjamn in #6221 -
The
updateQuery
function previously required byfetchMore
has been deprecated with a warning, and will be removed in the next major version of Apollo Client. Please consider using amerge
function to handle incoming data instead of relying onupdateQuery
.
@benjamn in #6464 -
Helper functions for generating common pagination-related field policies may be imported from
@apollo/client/utilities
. The most basic helper isconcatPagination
, which emulates the concatenation behavior of typicalupdateQuery
functions. A more sophisticated helper isoffsetLimitPagination
, which implements offset/limit-based pagination. If you are consuming paginated data from a Relay-friendly API, userelayStylePagination
. Feel free to use these helper functions as inspiration for your own field policies, and/or modify them to suit your needs.
@benjamn in #6465 -
Updated to work with
graphql@15
.
@durchanek in #6194 and #6279
@hagmic in #6328 -
Apollo Link core and HTTP related functionality has been merged into
@apollo/client
. Functionality that was previously available through theapollo-link
,apollo-link-http-common
andapollo-link-http
packages is now directly available from@apollo/client
(e.g.import { HttpLink } from '@apollo/client'
). TheApolloClient
constructor has also been updated to accept newuri
,headers
andcredentials
options. Ifuri
is specified, Apollo Client will take care of creating the necessaryHttpLink
behind the scenes.
@hwillson in #5412 -
The
gql
template tag should now be imported from the@apollo/client
package, rather than thegraphql-tag
package. Although thegraphql-tag
package still works for now, future versions of@apollo/client
may change the implementation details ofgql
without a major version bump.
@hwillson in #5451 -
@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.
@kamilkisiela in #5541 -
Several deprecated methods have been fully removed:
ApolloClient#initQueryManager
QueryManager#startQuery
ObservableQuery#currentResult
-
Apollo Client now supports setting a new
ApolloLink
(or link chain) afternew ApolloClient()
has been called, using theApolloClient#setLink
method.
@hwillson in #6193 -
The final time a mutation
update
function is called, it can no longer accidentally read optimistic data from other concurrent mutations, which ensures the use of optimistic updates has no lasting impact on the state of the cache after mutations have finished.
@benjamn in #6551 -
Apollo links that were previously maintained in https://github.com/apollographql/apollo-link have been merged into the Apollo Client project. They should be accessed using the new entry points listed in the migration guide.
@hwillson in #
InMemoryCache
⚠️ Note:InMemoryCache
has been significantly redesigned and rewritten in Apollo Client 3.0. Please consult the migration guide and read the new documentation to understand everything that has been improved.
-
The
InMemoryCache
constructor should now be imported directly from@apollo/client
, rather than from a separate package. Theapollo-cache-inmemory
package is no longer supported.The
@apollo/client/cache
entry point can be used to importInMemoryCache
without importing other parts of the Apollo Client codebase.
@hwillson in #5577 -
[BREAKING]
FragmentMatcher
,HeuristicFragmentMatcher
, andIntrospectionFragmentMatcher
have all been removed. We now recommend usingInMemoryCache
’spossibleTypes
option instead. For more information see the DefiningpossibleTypes
manually section of the docs.
@benjamn in #5073 -
[BREAKING] As promised in the Apollo Client 2.6 blog post, all cache results are now frozen/immutable.
@benjamn in #5153 -
[BREAKING] Eliminate "generated" cache IDs to avoid normalizing objects with no meaningful ID, significantly reducing cache memory usage. This might be a backwards-incompatible change if your code depends on the precise internal representation of normalized data in the cache.
@benjamn in #5146 -
[BREAKING]
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 custommerge
function is defined by a field policy for that field, within a type policy associated with the__typename
of the parent object.
@benjamn in #5603 -
[BREAKING]
InMemoryCache
now throws when data with missing or undefined query fields is written into the cache, rather than just warning in development.
@benjamn in #6055 -
[BREAKING]
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/orcache.modify
can be used to update the cache.
@benjamn in #5923 -
InMemoryCache
now supports tracing garbage collection and eviction. Note that the signature of theevict
method has been simplified in a potentially backwards-incompatible way.
@benjamn in #5310 -
[beta-BREAKING] Please note that the
cache.evict
method now requiresCache.EvictOptions
, though it pr...
v3.0.0-rc.0
Now that the release candidate phase of testing has begun, we will do our very best to avoid introducing any new features or breaking API changes, unless those changes are absolutely necessary to fix bugs.
We are very much aware of a number of outstanding bugs, and we fully intend to fix all known bugs before the final AC3 release, in addition to continuing to write and edit the documentation for new AC3 features: https://github.com/apollographql/apollo-client/milestone/14
If you have been waiting for a signal that the AC3 API is stable/frozen, this is it. However, if you are not interested in helping to identify and fix (or at least work around) the remaining issues, then you should wait for the final release before updating.
Changes: https://github.com/apollographql/apollo-client/blob/v3.0.0-rc.0/CHANGELOG.md
2.6.8
Apollo Client 2.6.8
Apollo Client (2.6.8)
-
Update the
fetchMore
type signature to acceptcontext
.
@koenpunt in #5147 -
Fix type for
Resolver
and use it in the definition ofResolvers
.
@peoplenarthax in #4943 -
Local state resolver functions now receive a
fragmentMap: FragmentMap
object, in addition to thefield: FieldNode
object, via theinfo
parameter.
@mjlyons in #5388 -
Documentation updates.
@tomquirk in #5645
@Sequoia in #5641
@phryneas in #5628
@AryanJ-NYC in #5560
GraphQL Anywhere (4.2.6)
- Fix
filter
edge case involvingnull
.
@lifeiscontent in #5110
Apollo Boost (0.4.7)
-
Replace
GlobalFetch
reference withWindowOrWorkerGlobalScope
.
@abdonrd in #5373 -
Add
assumeImmutableResults
typing to apollo boostPresetConfig
interface.
@bencoullie in #5571