- Consider only
result.data
(rather than all properties ofresult
) when settling cache feuds.
@danReynolds in #6777
- 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
- Re-export cache types from
@apollo/client/core
(and thus also@apollo/client
), again.
@benjamn in #6725
-
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
-
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
- Avoid duplicating
graphql/execution/execute
dependency in CommonJS bundle for@apollo/client/link/schema
, fixinginstanceof
errors reported in #6621 and #6614.
@benjamn in #6624
-
Make sure
useQuery
onCompleted
is not fired whenskip
istrue
.
@hwillson in #6589 -
Revert changes to
peerDependencies
inpackage.json
(#6594), which would have allowed using incompatible future versions ofgraphql
and/orreact
due to overly-permissive>=
version constraints.
@hwillson in #6605
⚠️ Note: As of 3.0.0, Apollo Client uses a new package name:@apollo/client
-
[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
- Helper functions for generating common pagination-related field policies may be imported from
-
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 #
⚠️ 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 previously supported positional arguments as well.
@danReynolds in #6141 @benjamn in #6364 -
Removing an entity object using the
cache.evict
method does not automatically remove dangling references to that entity elsewhere in the cache, but dangling references will be automatically filtered from lists whenever those lists are read from the cache. You can define a custom fieldread
function to customize this behavior. See #6412, #6425, and #6454 for further explanation.
-
-
Cache methods that would normally trigger a broadcast, like
cache.evict
,cache.writeQuery
, andcache.writeFragment
, can now be called with a named options object, which supports abroadcast: 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.
@benjamn in #6288 -
InMemoryCache
nowconsole.warn
s in development whenever non-normalized data is dangerously overwritten, with helpful links to documentation about normalization and custommerge
functions.
@benjamn in #6372 -
The result caching system (introduced in #3394) now tracks dependencies at the field level, rather than at the level of whole entity objects, allowing the cache to return identical (
===
) results much more often than before.
@benjamn in #5617 -
InMemoryCache
now has a method calledmodify
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)); }, }, });
This API gracefully handles cases where multiple field values are associated with a single field name, and also removes the need for updating the cache by reading a query or fragment, modifying the result, and writing the modified result back into the cache. Behind the scenes, the
cache.evict
method is now implemented in terms ofcache.modify
.
@benjamn in #5909 and #6178 -
InMemoryCache
provides a new API for storing client state that can be updated from anywhere:import { makeVar } from "@apollo/client" const v = makeVar(123) console.log(v()) // 123 console.log(v(v() + 1)) // 124 console.log(v()) // 124 v("asdf") // TS type error
These variables are reactive in the sense that updating their values invalidates any previously cached query results that depended on the old values.
@benjamn in #5799, #5976, and #6512 -
Various cache read and write performance optimizations, cutting read and write times by more than 50% in larger benchmarks.
@benjamn in #5948 -
The
cache.readQuery
andcache.writeQuery
methods now accept anoptions.id
string, which eliminates most use cases forcache.readFragment
andcache.writeFragment
, and skips the implicit conversion of fragment documents to query documents performed bycache.{read,write}Fragment
.
@benjamn in #5930 -
Support
cache.identify(entity)
for easily computing entity ID strings.
@benjamn in #5642 -
Support eviction of specific entity fields using
cache.evict(id, fieldName)
.
@benjamn in #5643 -
Make
InMemoryCache#evict
remove data from allEntityStore
layers.
@benjamn in #5773 -
Stop paying attention to
previousResult
inInMemoryCache
.
@benjamn in #5644 -
Improve optimistic update performance by limiting cache key diversity.
@benjamn in #5648 -
Custom field
read
functions can read from neighboring fields using thereadField(fieldName)
helper, and may also read fields from other entities by callingreadField(fieldName, objectOrReference)
.
@benjamn in #5651 -
Expose cache
modify
andidentify
to the mutateupdate
function.
@hwillson in #5956 -
Add a default
gc
implementation toApolloCache
.
@justinwaite in #5974
-
[BREAKING] The
QueryOptions
,MutationOptions
, andSubscriptionOptions
React Apollo interfaces have been renamed toQueryDataOptions
,MutationDataOptions
, andSubscriptionDataOptions
(to avoid conflicting with similarly named and exported Apollo Client interfaces). -
[BREAKING] Results with
loading: true
will no longer redeliver previous data, though they may provide partial data from the cache, when available.
@benjamn in #6566 -
[BREAKING?] Remove
fixPolyfills.ts
, except when bundling for React Native. If you have trouble withMap
orSet
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 whyfixPolyfills.native.js
is not included in your bundle.
@benjamn in #5962 -
The contents of the
@apollo/react-hooks
package have been merged into@apollo/client
, enabling the following all-in-oneimport
:import { ApolloClient, ApolloProvider, useQuery } from '@apollo/client';
-
React SSR features (previously accessed via
@apollo/react-ssr
) can now be accessed from the separate Apollo Client entry point of@apollo/client/react/ssr
. These features are not included in the default@apollo/client
bundle.
@hwillson in #6499
-
[BREAKING] Removed
graphql-anywhere
since it's no longer used by Apollo Client.
@hwillson in #5159 -
[BREAKING] Removed
apollo-boost
since Apollo Client 3.0 provides a boost like getting started experience out of the box.
@hwillson in #5217 -
[BREAKING] We are no longer exporting certain (intended to be) internal utilities. If you are depending on some of the lesser known exports from
apollo-cache
,apollo-cache-inmemory
, orapollo-utilities
, they may no longer be available from@apollo/client
.
@hwillson in #5437 and #5514Utilities that were previously externally available through the
apollo-utilities
package are now only available by importing from@apollo/client/utilities
.
@hwillson in #5683 -
Make sure all
graphql-tag
public exports are re-exported.
@hwillson in #5861 -
Fully removed
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.
@hwillson in #5227 -
Make sure
ApolloContext
plays nicely with IE11 when storing the shared context.
@ms in #5840 -
Migrated React Apollo HOC and Components functionality into Apollo Client, making it accessible from
@apollo/client/react/components
and@apollo/client/react/hoc
entry points.
@hwillson in #6558 -
Support passing a
context
object through the link execution chain when using subscriptions.
@sgtpepper43 in #4925 -
MockSubscriptionLink
now supports multiple subscriptions.
@dfrankland in #6081
-
useMutation
adjustments to help avoid an infinite loop / too many renders issue, caused by unintentionally modifying theuseState
based mutation result directly.
@hwillson in #5770 -
Missing
__typename
fields no longer cause theInMemoryCache#diff
result to be markedcomplete: false
, if those fields were added byInMemoryCache#transformDocument
(which callsaddTypenameToDocument
).
@benjamn in #5787 -
Fixed an issue that allowed
@client @export
based queries to lead to extra unnecessary network requests being fired.
@hwillson in #5946 -
Refined
useLazyQuery
types to help prevent runtime errors.
@benmosher in #5935 -
Make sure
@client @export
variables used in watched queries are updated each time the query receives new data that changes the value of the@export
variable.
@hwillson in #5986 -
Ensure
useMutation
passes a definederrorPolicy
option into its underlyingApolloClient.mutate()
call.
@jamesreggio in #5863 -
useQuery
: Prevent new data re-render attempts during an existing render. This helps avoid React 16.13.0's "Cannot update a component from inside the function body of a different component" warning (facebook/react#17099).
@hwillson in #6107 -
Expand
ApolloError
typings to includeServerError
andServerParseError
.
@dmarkow in #6319 -
Fast responses received over the link chain will no longer conflict with
skip
settings.
@hwillson in #6587
-
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
- Fix
filter
edge case involvingnull
.
@lifeiscontent in #5110
-
Replace
GlobalFetch
reference withWindowOrWorkerGlobalScope
.
@abdonrd in #5373 -
Add
assumeImmutableResults
typing to apollo boostPresetConfig
interface.
@bencoullie in #5571
-
Modify
ObservableQuery
to allow queries withnotifyOnNetworkStatusChange
to be notified when loading after an error occurs.
@jasonpaulos in #4992 -
Add
graphql
as apeerDependency
ofapollo-cache
andgraphql-anywhere
.
@ssalbdivad in #5081
- A new
ObservableQuery.resetQueryStoreErrors()
method is now available that can be used to clear outObservableQuery
query store errors.
@hwillson in #4941 - Documentation updates.
@michael-watson in #4940
@hwillson in #4969
- In all Apollo Client packages, the compilation of
lib/bundle.esm.js
tolib/bundle.cjs.js
andlib/bundle.umd.js
now uses Babel instead of Rollup, since Babel correctly compiles some edge cases that neither Rollup nor TypeScript compile correctly.
@benjamn in #4911
- The
isEqual
function has been reimplemented using thelodash.isequal
npm package, to better support circular references. Since thelodash.isequal
package is already used byreact-apollo
, this change is likely to decrease total bundle size.
@capaj in #4915
- In production,
invariant(condition, message)
failures will now include a unique error code that can be used to trace the error back to the point of failure.
@benjamn in #4521
-
If you can be sure your application code does not modify cache result objects (see
freezeResults
note below), you can unlock substantial performance improvements by communicating this assumption vianew ApolloClient({ assumeImmutableResults: true })
which allows the client to avoid taking defensive snapshots of past results using
cloneDeep
, as explained by @benjamn in #4543. -
Identical overlapping queries are now deduplicated internally by
apollo-client
, rather than using theapollo-link-dedup
package.
@benjamn in commit 7cd8479f -
The
FetchPolicy
type has been split into two types, so that passingcache-and-network
toApolloClient#query
is now forbidden at the type level, whereas previously it was forbidden by a runtimeinvariant
assertion:export type FetchPolicy = | 'cache-first' | 'network-only' | 'cache-only' | 'no-cache' | 'standby'; export type WatchQueryFetchPolicy = | FetchPolicy | 'cache-and-network';
The exception thrown if you ignore the type error has also been improved to explain the motivation behind this restriction.
Issue #3130 (comment) and commit cf069bc7 -
Avoid updating (and later invalidating) cache watches when
fetchPolicy
is'no-cache'
.
@bradleyayers in PR #4573, part of issue #3452 -
Remove temporary
queryId
afterfetchMore
completes.
@doomsower in #4440 -
Call
clearStore
callbacks after clearing store.
@ds8k in #4695 -
Perform all
DocumentNode
transforms once, and cache the results.
@benjamn in #4601 -
Accommodate
@client @export
variable changes inObservableQuery
.
@hwillson in #4604 -
Support the
returnPartialData
option for watched queries again.
@benjamn in #4743 -
Preserve
networkStatus
for incompletecache-and-network
queries.
@benjamn in #4765 -
Preserve
cache-and-network
fetchPolicy
when refetching.
@benjamn in #4840 -
Update the React Native docs to remove the request for external example apps that we can link to. We're no longer going to manage a list of external example apps.
@hwillson in #4531 -
Polling queries are no longer batched together, so their scheduling should be more predictable.
@benjamn in #4800
-
Support
new InMemoryCache({ freezeResults: true })
to help enforce immutability.
@benjamn in #4514 -
Allow
IntrospectionFragmentMatcher
to match fragments against the rootQuery
, asHeuristicFragmentMatcher
does.
@rynobax in #4620 -
Rerential identity (
===
) of arrays in cache results will now be preserved for unchanged data.
@benjamn in commit f3091d6a -
Avoid adding
__typename
field to@client
selection sets that have been@export
ed as input variables.
@benjamn in #4784
- The
graphql
function can now be configured to ignore@include
and@skip
directives (useful when walking a fragment to generate prop types or filter result data).
@GreenGremlin in #4373
- Introduces new local state management features (client-side schema
and local resolver /
@client
support) and many overall code improvements, to help reduce the Apollo Client bundle size.
#4361 - Revamped CJS and ESM bundling approach with Rollup.
@rosskevin in #4261 - Fixes an issue where the
QueryManager
was accidentally returning cached data fornetwork-only
queries.
@danilobuerger in #4352 - Fixed an issue in the repo
.gitattributes
that was causing binary files to have their line endings adjusted, and cleaned up corrupted documentation images (ref: #4232).
@rajington in #4438 - Improve (and shorten) query polling implementation.
PR #4337
-
Resolve "invalidate" -> "invalidated" typo in
QueryManager
.
@quazzie in #4041 -
Properly type
setQuery
and fix now typed callers.
@danilobuerger in #4369 -
Align with the React Apollo decision that result
data
should beTData | undefined
instead ofTData | {}
.
@danilobuerger in #4356 -
Documentation updates.
@danilobuerger in #4340
@justyn-clark in #4383
@jtassin in #4287
@Gongreg in #4386
@davecardwell in #4399
@michaelknoch in #4384
- Support
ApolloClient#stop
method for safe client disposal.
PR #4336
- Added explicit dependencies on the
tslib
package to all client packages to fix Issue #4332.
- Reverted some breaking changes accidentally released in a patch version (2.4.10). PR #4334
-
The
apollo-client
package no longer exports aprintAST
function fromgraphql/language/printer
. If you need this functionality, import it directly:import { print } from "graphql/language/printer"
-
Query polling now uses a simpler scheduling strategy based on a single
setTimeout
interval rather than multiplesetInterval
timers. The new timer fires at the rate of the fastest polling interval, and queries with longer polling intervals fire whenever the time elapsed since they last fired exceeds their desired interval.
PR #4243
-
The
optimism
npm package has been updated to a version (0.6.9) that provides its own TypeScript declarations, which should fix problems like Issue #4327.
PR #4331 -
Error messages involving GraphQL queries now print the queries using
JSON.stringify
instead of theprint
function exported by thegraphql
package, to avoid pulling unnecessary printing logic into your JavaScript bundle.
PR #4234 -
The
QueryKeyMaker
abstraction has been removed, meaning that cache results for non-identical queries (or sub-queries) with equivalent structure will no longer be cached together. This feature was a nice optimization in certain specific use cases, but it was not worth the additional complexity or bundle size.
PR #4245
- The
flattenSelections
helper function is no longer exported fromapollo-utilities
, sincegetDirectiveNames
has been reimplemented without usingflattenSelections
, andflattenSelections
has no clear purpose now. If you need the old functionality, use a visitor:import { visit } from "graphql/language/visitor"; function flattenSelections(selection: SelectionNode) { const selections: SelectionNode[] = []; visit(selection, { SelectionSet(ss) { selections.push(...ss.selections); } }); return selections; }
-
Apollo Client has been updated to use
graphql
14.x as a dev dependency.
@hwillson in #4233 -
The
onClearStore
function can now be used to register callbacks that should be triggered when callingclearStore
.
@joe-re in #4082 -
Make
isApolloError
available for external use.
@FredyC in #4223 -
The
QueryManager
now callscomplete
on the observables used by Apollo Client's Subscription handling. This gives finite subscriptions a chance to handle cleanup.
@sujeetsr in #4290 -
Documentation updates.
@lifedup in #3931
@Dem0n3D in #4008
@anand-sundaram-zocdoc in #4009
@mattphoto in #4026
@birge in #4029
@mxstbr in #4127
@Caerbannog in #4140
@jedwards1211 in #4179
@nutboltu in #4182
@CarloPalinckx in #4189
@joebernard in #4206
@evans in #4213
@danilobuerger in #4214
@stubailo in #4220
@haysclark in #4255
@shelmire in #4266
@peggyrayzis in #4280
@caydie-tran in #4300
- Transformation utilities have been refactored to work with
graphql
14.x. GraphQL AST's are no longer being directly modified.
@hwillson in #4233
-
The speed and memory usage of optimistic reads and writes has been improved dramatically using a new layering technique that does not require copying the non-optimistic contents of the cache.
PR #4319 -
The
RecordingCache
abstraction has been removed, and thus is no longer exported fromapollo-cache-inmemory
.
PR #4319 -
Export the optimism
wrap
function using ES2015 export syntax, instead of CommonJS.
@ardatan in #4158
-
Documentation and config updates.
@justinanastos in #4187
@PowerKiKi in #3693
@nandito in #3865 -
Schema/AST tranformation utilities have been updated to work properly with
@client
directives.
@justinmakaila in #3482
-
Avoid using
DepTrackingCache
for optimistic reads. PR #4521 -
When creating an
InMemoryCache
object, it's now possible to disable the result caching behavior introduced in #3394, either for diagnostic purposes or because the benefit of caching repeated reads is not worth the extra memory usage in your application:new InMemoryCache({ resultCaching: false })
Part of PR #4521.
- The
ApolloClient
constructor has been updated to acceptname
andversion
params, that can be used to support Apollo Server Client Awareness functionality. These client awareness properties are passed into the defined Apollo Link chain, and are then ultimately sent out as custom headers with outgoing requests.
@hwillson in #4154
- No changes.
- No changes.
- No changes.
- No changes.
- No changes.
-
Added some
return
s to prevent errors withnoImplicitReturns
TypeScript rule. PR #4137 -
Exclude the
src/
directory when publishingapollo-cache-inmemory
. Issue #4083
-
Optimistic tests cleanup. PR #3834 by @joshribakoff
-
Documentation updates. PR #3840 by @chentsulin and PR #3844 by @lorensr
-
Implement
ObservableQuery#isDifferentFromLastResult
to fix Issue #4054 and Issue #4031. PR #4069
- Add
readQuery
test to make sure options aren't mutated. @CarloPalinckx in #3838
- Avoid modifying source objects when merging cache results. Issue #4081 PR #4089
-
Discard property accessor functions in
cloneDeep
helper, to fix issue #4034. -
Unconditionally remove
cloneDeep
property accessors. PR #4039 -
Avoid copying non-enumerable and/or
Symbol
keys incloneDeep
. PR #4052
-
Throw when querying non-scalar objects without a selection set. Issue #4025 PR #4038
-
Work around spec non-compliance of
Map#set
andSet#add
in IE11. Issue #4024 PR #4012
-
Add additional checks to make sure we don't try to set the network status of queries in the store, when the store doesn't exist.
@i6mi6 in #3914 -
Documentation updates.
@shanonvl in #3925
@ojh102 in #3920
@Bkucera in #3919
@j4chou in #3915
@billfienberg in #3886
@TLadd in #3884 -
The
ObservableQuery
class now makes a deep clone oflastResult
when first received, so that theisDifferentResult
logic will not be confused if the result object is modified later. Issue #3992 PR #4032
-
Optimize repeated
apollo-cache-inmemory
reads by caching partial query results, for substantial performance improvements. As a consequence, watched queries will not be rebroadcast unless the data have changed. PR #3394 -
Include root ID and fragment matcher function in cache keys computed by
StoreReader#executeStoreQuery
andexecuteSelectionSet
, and work around bugs in the React NativeMap
andSet
polyfills. PR #3964 React Native PR #21492 (pending) -
The
apollo-cache-inmemory
package now allowsgraphql@^14.0.0
as a peer dependency. Issue #3978 -
The
apollo-cache-inmemory
package now correctly broadcasts changes even when the new data is===
to the old data, since the contents of the data object may have changed. Issue #3992 PR #4032
- Make
graphql-anywhere
filter
function generic (typescript).
@minznerjosh in #3929
- The
fclone
package has been replaced with a customcloneDeep
implementation that is tolerant of cycles, symbol properties, and non-enumerable properties. PR #4032
- Remove duplicate InMemoryCache export for Babel 6 compatibility. Issue #3910 PR #3932
- No changes.
- Apollo Client no longer deep freezes query results. @hwillson in #3883
- A new
clearStore
method has been added, that will remove all data from the store. UnlikeresetStore
, it will not refetch active queries after removing store data. @hwillson in #3885
- Replace the custom
cloneDeep
implementation withfclone
, to avoid crashing when encountering circular references.
@hwillson in #3881
- No changes.
- No changes.
- No changes.
- No changes.
-
mutate
'srefetchQueries
option now allows queries to include a customcontext
option. Thiscontext
will be used when refetching the query. For example:context = { headers: { token: 'some auth token', }, }; client.mutate({ mutation: UPDATE_CUSTOMER_MUTATION, variables: { userId: user.id, firstName, ... }, refetchQueries: [{ query: CUSTOMER_MESSAGES_QUERY, variables: { userId: user.id }, context, }], context, });
The
CUSTOMER_MESSAGES_QUERY
above will be refetched usingcontext
. Normally queries are refetched using the original context they were first started with, but this provides a way to override the context, if needed.
@hwillson in #3852
- Various internal infrastructure changes related to building, bundling, testing, etc. @hwillson in #3817
- Various internal infrastructure changes related to building, bundling, testing, etc. @hwillson in #3817
- Various internal infrastructure changes related to building, bundling, testing, etc. @hwillson in #3817
- Various internal infrastructure changes related to building, bundling, testing, etc. @hwillson in #3817
- Various internal infrastructure changes related to building, bundling, testing, etc. @hwillson in #3817
- Add proper error handling for subscriptions. If you have defined an
error
handler on your subscription observer, it will now be called when an error comes back in a result, and thenext
handler will be skipped (similar to how we're handling errors with mutations). Previously, the error was just passed in the result to thenext
handler. If you don't have anerror
handler defined, the previous functionality is maintained, meaning the error is passed in the result, giving the next handler a chance to deal with it. This should help address backwards compatibility (and is the reason for the minor version bumo in this release).
@clayne11 in #3800 - Allow an
optimistic
param to be passed intoApolloClient.readQuery
andApolloClient.readFragment
, that when set totrue
, will allow optimistic results to be returned. Isfalse
by default.
@jay1337 in #2429 - Optimistic tests cleanup.
@joshribakoff in #3713 - Make sure each package has its own
.npmignore
, so they're taken into consideration when publishing via lerna.
@hwillson in #3828 - Documentation updates.
@toolness in #3804
@pungggi in #3798
@lorensr in #3748
@joshribakoff in #3730
@yalamber in #3819
@pschreibs85 in #3812
@msreekm in #3808
@kamaltmo in #3806
@lorensr in #3739
@brainkim in #3680
- No changes.
- No changes.
- No changes.
- No changes.
- Adjusted the
graphql
peer dependency to cover explicit minor ranges. Since the ^ operator only covers any minor version if the major version is not 0 (since a major version of 0 is technically considered development by semver 2), the current ^0.11.0 || ^14.0.0 graphql range doesn't cover 0.12.* or 0.13.*. This fixes theapollo-client@X has incorrect peer dependency "graphql@^0.11.0 || ^14.0.0"
errors that people might have seen usinggraphql
0.12.x or 0.13.x.
@hwillson in #3746 - Document
setVariables
internal API status.
@PowerKiKi in #3692 - Corrected
ApolloClient.queryManager
typing as it may beundefined
.
@danilobuerger in #3661 - Make sure using a
no-cache
fetch policy with subscriptions prevents data from being cached.
@hwillson in #3773 - Fixed an issue that sometimes caused empty query results, when using the
no-cache
fetch policy.
@hwillson in #3777 - Documentation updates.
@hwillson in #3750
@hwillson in #3754
@TheMightyPenguin in #3725
@bennypowers in #3668
@hwillson in #3762
@chentsulin in #3688
@chentsulin in #3687
@ardouglass in #3645
@hwillson in #3764
@hwillson in #3767
@hwillson in #3774
@hwillson in #3779
- No changes.
- No changes.
- No changes.
- No changes.
- No changes.
- Release 2.3.6 broke Typescript compilation.
QueryManager
'sgetQueryWithPreviousResult
method included an invalidvariables
return type in the auto-generatedcore/QueryManager.d.ts
declaration file. The type definition had a locally referenced path, that appears to have been caused by the typescript compiler getting confused at compile/publish time.getQueryWithPreviousResult
return types are now excplicity identified, which helps Typescript avoid the local type reference. For more details, see #3729.
@hwillson in #3731
- No changes.
- Documentation updates.
@ananth99 in #3599
@hwillson in #3635
@JakeDawkins in #3642
@hwillson in #3644
@gbau in #3644
@chentsulin in #3608
@MikaelCarpenter in #3609
@Gamezpedia in #3612
@jinxac in #3647
@abernix in #3705
@dandv in #3703
@hwillson in #3580 - Updated
graphql
peerDependencies
to handle 14.x versions.
@ivank in #3598 - Add optional generic type params for variables on low level methods.
@mvestergaard in #3588 - Add a new
awaitRefetchQueries
config option to the Apollo Clientmutate
function, that when set totrue
will wait for allrefetchQueries
to be fully refetched, before resolving the mutation call.awaitRefetchQueries
isfalse
by default.
@jzimmek in #3169
- Allow
fetch
to be given as a configuration option toApolloBoost
.
@mbaranovski in #3590 - The
apollo-boost
ApolloClient
constructor now warns about unsupported options.
@quentin- in #3551
- No changes.
- Add
__typename
andid
properties todataIdFromObject
parameter (typescript)
@jfurler in #3641 - Fixed an issue caused by
dataIdFromObject
considering returned 0 values to be falsy, instead of being a valid ID, which lead to the store not being updated properly in some cases.
@hwillson in #3711
- No changes.
- Add support for arrays to
graphql-anywhere
's filter utility.
@jsweet314 in #3591 - Fix
Cannot convert object to primitive value
error that was showing up when attempting to report a missing property on an object.
@benjie in #3618
- Internal code formatting updates.
- @chentsulin in #3574
- Documentation updates.
- @andtos90 in #3596
- @serranoarevalo in #3554
- @cooperka in #3594
- @pravdomil in #3587
- @excitement-engineer in #3309
- No changes.
- No changes.
- No changes.
- Removed unnecessary whitespace from error message.
- No changes.
- Export the
QueryOptions
interface, to make sure it can be used by other projects (likeapollo-angular
). - Fixed an issue caused by typescript changes to the constructor
defaultOptions
param, that preventedquery
defaults from passing type checks. (@hwillson in #3585)
- No changes
- No changes
- No changes
- No changes
- No changes
- Typescript improvements. Made observable query parameterized on data and
variables:
ObservableQuery<TData, TVariables>
(@excitement-engineer in #3140) - Added optional generics to cache manipulation methods (typescript). (@mvestergaard in #3541)
- Typescript improvements. Created a new
QueryOptions
interface that is now used byApolloClient.query
options, instead of the previousWatchQueryOptions
interface. This helps reduce confusion (especially in the docs) that made it look likeApolloClient.query
acceptedApolloClient.watchQuery
only options, likepollingInterval
. (@hwillson in #3569)
- Allow
cache
to be given as a configuration option toApolloBoost
. (@dandean in #3561) - Allow
headers
andcredentials
to be passed in as configuration parameters to theapollo-boost
ApolloClient
constructor. (@rzane in #3098)
- Added optional generics to cache manipulation methods (typescript). (@mvestergaard in #3541)
- Added optional generics to cache manipulation methods (typescript). (@mvestergaard in #3541)
- Restore non-enumerability of
resultFields[ID_KEY]
. (@benjamn in #3544) - Cache query documents transformed by InMemoryCache. (@benjamn in #3553)
- Store key names generated by
getStoreKeyName
now leverage a more deterministic approach to handling JSON based strings. This prevents store key names from differing when usingargs
like{ prop1: 'value1', prop2: 'value2' }
and{ prop2: 'value2', prop1: 'value1' }
. (@gdi2290 in #2869) - Avoid needless
hasOwnProperty
check indeepFreeze
. (@benjamn in #3545)
- No new changes.
- Fix SSR and
cache-and-network
fetch policy (@dastoori in #3372) - Fixed an issue where the
updateQuery
method passed toObservableQuery.fetchMore
was receiving the original query variables, instead of the new variables that it used to fetch more data. (@abhiaiyer91 in #3500) - Fixed an issue involving
Object.setPrototypeOf()
not working on JSC (Android), by instead setting theprototype
ofthis
manually. (@seklyza in #3306) - Added safeguards to make sure
QueryStore.initQuery
andQueryStore.markQueryResult
don't try to set the network status of afetchMoreForQueryId
query, if it does not exist in the store. This was happening when a query component was unmounted while afetchMore
was still in flight. (@conrad-vanl in #3367, @doomsower in #3469)
- Various internal code cleanup, tooling and dependency changes.
- Various internal code cleanup, tooling and dependency changes.
- Fixed an issue that caused fragment only queries to sometimes fail. (@abhiaiyer91 in #3507)
- Fixed cache invalidation for inlined mixed types in union fields within arrays. (@dferber90 in #3422)
- Make
maybeDeepFreeze
a little more defensive, by always usingObject.prototype.hasOwnProperty
(to avoid cases where the object being frozen doesn't have its ownhasOwnProperty
). (@jorisroling in #3418) - Remove certain small internal caches to prevent memory leaks when using SSR. (@brunorzn in #3444)