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.