fix(deps): update dependency @apollo/client to v4.2.0#380
Open
svc-secops wants to merge 1 commit into
Open
Conversation
3ce9842 to
38e817a
Compare
38e817a to
fc18f53
Compare
fc18f53 to
8e42377
Compare
8e42377 to
d3ba312
Compare
d3ba312 to
41ccf50
Compare
41ccf50 to
e40606c
Compare
e40606c to
604d91d
Compare
604d91d to
9180954
Compare
9180954 to
bbe7100
Compare
bbe7100 to
ae8b8df
Compare
ae8b8df to
64b2bd7
Compare
64b2bd7 to
a7b7bed
Compare
a7b7bed to
dbc2024
Compare
dbc2024 to
c0da95a
Compare
c0da95a to
c26a432
Compare
c26a432 to
3e47e1a
Compare
3e47e1a to
9c50e96
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
4.0.3→4.2.0Release Notes
apollographql/apollo-client (@apollo/client)
v4.2.0Compare Source
Minor Changes
#13132
f3ce805Thanks @phryneas! - Introduce "classic" and "modern" method and hook signatures.Apollo Client 4.2 introduces two signature styles for methods and hooks. All signatures previously present are now "classic" signatures, and a new set of "modern" signatures are added alongside them.
Classic signatures are the default and are identical to the signatures before Apollo Client 4.2, preserving backward compatibility. Classic signatures still work with manually specified TypeScript generics (e.g.,
useSuspenseQuery<MyData>(...)). However, manually specifying generics has been discouraged for a long time—instead, we recommend usingTypedDocumentNodeto automatically infer types, which provides more accurate results without any manual annotations.Modern signatures automatically incorporate your declared
defaultOptionsinto return types, providing more accurate types. Modern signatures infer types from the document node and do not support manually passing generic type arguments; TypeScript will produce a type error if you attempt to do so.Methods and hooks automatically switch to modern signatures the moment any non-optional property is declared in
DeclareDefaultOptions. The switch happens across all methods and hooks globally:Users can also manually switch to modern signatures without declaring any
defaultOptions, for example when wanting accurate type inference without relying on globaldefaultOptions:Users can do a global
DeclareDefaultOptionstype augmentation and then manually switch back to "classic" for migration purposes:Note that this is not recommended for long-term use. When combined with
DeclareDefaultOptions, switching back to classic results in the same incorrect types as before Apollo Client 4.2—methods and hooks will not reflect thedefaultOptionsyou've declared.#13130
dd12231Thanks @jerelmiller! - Improve the accuracy ofclient.queryreturn type to better detect the currenterrorPolicy. Thedataproperty is no longer nullable when theerrorPolicyisnone. This makes it possible to remove theundefinedchecks or optional chaining in most cases.#13210
1f9a428Thanks @jerelmiller! - Add support for automatic event-based refetching, such as window focus.The
RefetchEventManagerclass handles automatic refetches in response to events. Apollo Client provides built-in sources for window focus and network reconnect aswindowFocusSourceandonlineSource.Event refetching is fully opt-in. Create and pass a
RefetchEventManagerinstance to theApolloClientconstructor to activate the event listeners.By default, all active queries refetch when the events fire. Queries can opt out per-event or disable all event refetches:
To enable per-query opt-in rather than opt-out, set
defaultOptions.watchQuery.refetchOntofalseand enable it per-query instead.When
defaultOptions.watchQuery.refetchOnand per-queryrefetchOnoptions are provided, the objects are merged together.Custom events
You can also add your own custom events that trigger refetches. Register your event name and payload type using TypeScript module augmentation, then provide a source function that returns an Observable. The source's emitted value becomes the event's
payload.Manually trigger an event refetch
Refetches can be triggered imperatively by calling
emitwith the event name and its payload (if any).Sourceless events
A source that has no automatic detection logic but still wants imperative
emitsupport can be declared astrue. Type the event asvoidto omit the payload argument.Note: Calling
emiton an event without a registered source will log a warning and result in a no-op.Custom handlers
When an event fires, the default handler calls
client.refetchQueries({ include: "active" })filtered by each query'srefetchOnsetting. You can override the handler for an event to add your own custom filtering. For example, to refetch all queries, includingstandbyqueries, define a handler for the event:Handlers must return either a
RefetchQueriesResultorvoid. Returningvoidskips refetching for the event.#13232
f1b541fThanks @jerelmiller! - Version bump torc.#13206
08fccabThanks @jerelmiller! - Extend thedefaultOptionstype-safety work toclient.mutateanduseMutation.The
errorPolicyoption now flows through to the result types for mutations in the same way it already does for queries:ApolloClient.MutateResult<TData, TErrorPolicy>mapserrorPolicyto the concrete shape ofdataanderror:"none"→{ data: TData; error?: never }"all"→{ data: TData | undefined; error?: ErrorLike }"ignore"→{ data: TData | undefined; error?: never }client.mutateanduseMutationpick up the declareddefaultOptions.mutate.errorPolicyand the expliciterrorPolicyon each call to narrow return types accordingly.useMutation.Result.erroris narrowed toundefinedwhenerrorPolicyis"ignore", sinceclient.mutatenever resolves with an error in that case.DeclareDefaultOptions.Mutatealready acceptederrorPolicy; the new behavior is that once you declare it, hook and method return types reflect it:Setting
errorPolicyon an individual call overrides the default for that call's return type.#13222
b93c172Thanks @jerelmiller! - Extend thedefaultOptionstype-safety work topreloadQuery(returned fromcreateQueryPreloader). Defaults declared inDeclareDefaultOptions.WatchQuerynow work withpreloadQueryto ensure thePreloadedQueryRef's data states are correctly set.#13132
f3ce805Thanks @phryneas! - Synchronize method and hook return types withdefaultOptions.Prior to this change, the following code snippet would always apply:
While these types are generally correct, if you were to set
errorPolicy: 'all'as a default option, the type ofresult.datafor the first query would remainTDatainstead of changing toTData | undefinedto match the runtime behavior.We are now enforcing that certain
defaultOptionstypes need to be registered globally. This means that if you want to useerrorPolicy: 'all'as a default option for a query, you will need to register its type like this:Once this type declaration is in place, the type of
result.datain the above example will correctly be changed toTData | undefined, reflecting the possibility that if an error occurs,datamight beundefined. Manually specifyinguseSuspenseQuery(MY_QUERY, { errorPolicy: "none" });changesresult.datatoTDatato reflect the local override.This change means that you will need to declare your default options types in order to use
defaultOptionswithApolloClient, otherwise you will see a TypeScript error.Without the type declaration, the following (previously valid) code will now error:
If you are creating multiple instances of Apollo Client with conflicting default options and you cannot register a single
defaultOptionsvalue as a result, you can relax the constraints by declaring those options as union types covering all values used by all clients. The properties can be required (to enforce them indefaultOptions) or optional (if some constructor calls won't pass a value):With this declaration, the
ApolloClientconstructor accepts any of those values indefaultOptions. The tradeoff is that hook and method return types become more generic. For example, callinguseSuspenseQuerywithout an expliciterrorPolicywill return a result typed as if all error policies are possible, since TypeScript can't know which specific value your instance uses at runtime.Note that making a property optional (
errorPolicy?:) is equivalent to adding the TypeScript default value ("none") to the union. SoerrorPolicy?: "all" | "ignore"has the same effect on return types aserrorPolicy: "none" | "all" | "ignore", because TypeScript assumes the option could also be absent (i.e.,"none").You can also use a partial union that only lists the values you actually use. For example, if you only ever use
"all"or"ignore", declareerrorPolicy: "all" | "ignore"(required) to keep the union narrow and avoid unused values broadening your signatures unnecessarily.Patch Changes
#13217
790f987Thanks @jerelmiller! - Fix the deprecation for the classic signatures for function overloads that rely on type inference from aTypedDocumentNode. The deprecation now only applies to classic signatures that provide explicit type arguments to encourage the use ofTypedDocumentNode.#13166
0537d97Thanks @jerelmiller! - Release changes in 4.1.5 and 4.1.6.#13215
54c9eb7Thanks @jerelmiller! - Ensure the options object for theuseQuery,useSuspenseQuery, anduseBackgroundQueryhooks provide proper IntelliSense suggestions.#13229
9a7f65aThanks @jerelmiller! - FixrefetchOnmerging whendefaultOptions.watchQuery.refetchOnis set to a non-object value (false,true, or a function) and the per-queryrefetchOnis an object. Previously the per-query object completely replaced the default so unspecified events fell back to "enabled" regardless of the default.The
defaultOptionsvalue now applies to any event the per-query object does not explicitly configure:false- unspecified events stay disabledtrue- unspecified events refetch#13230
b25b659Thanks @jerelmiller! - Add the ability to override the default event handler onRefetchEventManager. The default handler runs when no per-source handler is configured for an event. Provide a custom handler via thedefaultHandlerconstructor option or thesetDefaultEventHandlerinstance method.v4.1.9Compare Source
Patch Changes
099954bThanks @copilot-swe-agent! - Remove theworkspacesfield from the publishedpackage.jsonindistto avoid Yarn v1 warnings about workspaces requiring private packages.v4.1.8Compare Source
Patch Changes
8a51ea6Thanks @phryneas! - Ship agent skill for usage with @tanstack/intent — the skill is now bundled in the npm package underskills/apollo-client/and discoverable byintent list.For more context, see the TanStack Intent QuickStart.
v4.1.7Compare Source
Patch Changes
bb3fd9bThanks @jerelmiller! - Fix RxJS interop issue with the observable returned byWebSocketLink.v4.1.6Compare Source
Patch Changes
#13128
6c0b8e4Thanks @pavelivanov! - FixuseQueryhydration mismatch whenssr: falseandskip: trueare used togetherWhen both options were combined, the server would return
loading: false(becauseuseSSRQuerychecksskipfirst), but the client'sgetServerSnapshotwas returningssrDisabledResultwithloading: true, causing a hydration mismatch.v4.1.5Compare Source
Patch Changes
#13155
3ba1583Thanks @jerelmiller! - Fix an issue whereuseQuerywould poll withpollIntervalwhenskipwas initialized totrue.#13135
fd42142Thanks @jerelmiller! - Fix issue whereclient.querywould apply options fromdefaultOptions.watchQuery.v4.1.4Compare Source
Patch Changes
578081fThanks @Re-cool! - EnsurePersistedQueryLinkmergeshttpandfetchOptionscontext values instead of overwriting them.v4.1.3Compare Source
Patch Changes
#13111
bf46fe0Thanks @RogerHYang! - FixcreateFetchMultipartSubscriptionto support cancellation viaAbortControllerPreviously, calling
dispose()orunsubscribe()on a subscription created bycreateFetchMultipartSubscriptionhad no effect - the underlying fetch request would continue running until completion. This was because noAbortControllerwas created or passed tofetch(), and no cleanup function was returned from the Observable.v4.1.2Compare Source
Patch Changes
#13105
8b62263Thanks @phryneas! -ssrMode,ssrForceFetchDelayorprioritizeCacheValuesshould not overridefetchPolicy: 'cache-only',fetchPolicy: 'no-cache',fetchPolicy: 'standby',skip: true, orskipTokenwhen reading the initial value of anObservableQuery.#13105
8b62263Thanks @phryneas! - FixskipTokeninuseQuerywithprerenderStaticand related SSR functions.#13105
8b62263Thanks @phryneas! - Avoid fetches withfetchPolicy: no-cacheinuseQuerywithprerenderStaticand related SSR functions.v4.1.1Compare Source
Patch Changes
dee7dcfThanks @jerelmiller! - Ensure@clientfields that are children of aliased server fields are resolved correctly.v4.1.0Compare Source
Minor Changes
#13043
65e66caThanks @jerelmiller! - Supportheaderstransport for enhanced client awareness.#12927
785e223Thanks @jerelmiller! - You can now provide a callback function as thecontextoption on themutatefunction returned byuseMutation. The callback function is called with the value of thecontextoption provided to theuseMutationhook. This is useful if you'd like to merge the context object provided to theuseMutationhook with a value provided to themutatefunction.#12923
94ea3e3Thanks @jerelmiller! - Fix an issue where deferred payloads that returned arrays with fewer items than the original cached array would retain items from the cached array. This change includes@streamarrays where stream arrays replace the cached arrays.#12927
96b531fThanks @jerelmiller! - Don't set the fallback value of a@clientfield tonullwhen areadfunction is defined. Instead thereadfunction will be called with anexistingvalue ofundefinedto allow default arguments to be used to set the returned value.When a
readfunction is not defined nor is there a defined resolver for the field, warn and set the value tonullonly in that instance.#12927
45ebb52Thanks @jerelmiller! - Add support forfrom: nullinclient.watchFragmentandcache.watchFragment. Whenfromisnull, the emitted result is:#12926
2b7f2c1Thanks @jerelmiller! - Support the newer incremental delivery format for the@deferdirective implemented ingraphql@17.0.0-alpha.9. Import theGraphQL17Alpha9Handlerto use the newer incremental delivery format with@defer.#12927
45ebb52Thanks @jerelmiller! - Add support for arrays withuseFragment,useSuspenseFragment, andclient.watchFragment. This allows the ability to use a fragment to watch multiple entities in the cache. Passing an array tofromwill returndataas an array where each array index corresponds to the index in thefromarray.#12927
45ebb52Thanks @jerelmiller! - Add agetCurrentResultfunction to the observable returned byclient.watchFragmentandcache.watchFragmentthat returns the current value for the watched fragment.#13038
109efe7Thanks @jerelmiller! - Add thefromoption toreadFragment,watchFragment, andupdateFragment.#12918
2e224b9Thanks @jerelmiller! - Add support for the@streamdirective on both theDefer20220824Handlerand theGraphQL17Alpha2Handler.#13056
b224efcThanks @jerelmiller! -InMemoryCacheno longer filters out explicitly returnedundefineditems fromreadfunctions for array fields. This now makes it possible to createreadfunctions on array fields that return partial data and trigger a fetch for the full list.#13058
121a2cbThanks @jerelmiller! - Add anextensionsoption tocache.write,cache.writeQuery, andclient.writeQuery. This makesextensionsavailable in cachemergefunctions which can be accessed with the other merge function options.As a result of this change, any
extensionsreturned in GraphQL operations are now available inmergein the cache writes for these operations.#12927
96b531fThanks @jerelmiller! - Add an abstractresolvesClientFieldfunction toApolloCachethat can be used by caches to tellLocalStateif it can resolve a@clientfield when a local resolver is not defined.LocalStatewill emit a warning and set a fallback value ofnullwhen no local resolver is defined andresolvesClientFieldreturnsfalse, or isn't defined. ReturningtruefromresolvesClientFieldsignals that a mechanism in the cache will set the field value. In this case,LocalStatewon't set the field value.#13078
bf1e0dcThanks @phryneas! - Use the default stream merge function for@streamfields only if stream info is present. This change means that using the olderDefer20220824Handlerwill not use the default stream merge function and will instead truncate the streamed array on the first chunk.Patch Changes
#12884
d329790Thanks @phryneas! - Ensure thatPreloadedQueryRefinstances are unsubscribed when garbage collected#13086
1a1d408Thanks @phryneas! - Change the returned value fromnullto{}when all fields in a query were skipped.This also fixes a bug where
useSuspenseQuerywould suspend indefinitely when all fields were skipped.#13010
7627000Thanks @jerelmiller! - Fix an issue where errors parsed from incremental chunks inErrorLinkmight throw when using theGraphQL17Alpha9Handler.#12927
45ebb52Thanks @jerelmiller! - Deduplicate watches created byuseFragment,client.watchFragment, andcache.watchFragmentthat contain the same fragment, variables, and identifier. This should improve performance in situations where auseFragmentor aclient.watchFragmentis used to watch the same object in multiple places of an application.#12927
259ae9bThanks @jerelmiller! - AllowFragmentTypenot only to be called asFragmentType<TData>, but also asFragmentType<TypedDocumentNode>.#12925
5851800Thanks @jerelmiller! - Fix an issue where callingfetchMorewith@deferor@streamwould not rerender incremental results as they were streamed.#12927
9e55188Thanks @jerelmiller! - Truncate@streamarrays only on last chunk by default.#13083
f3c2be1Thanks @phryneas! - Expose theExtensionsWithStreamInfotype forextensionsinCache.writeQuery,Cache.writeandCache.updateso other cache implementations also can correctly access them.#12923
94ea3e3Thanks @jerelmiller! - Improve the cache data loss warning message whenexistingorincomingis an array.#12927
4631175Thanks @jerelmiller! - Ignore top-leveldatavalues on subsequent chunks in incremental responses.#12927
2be8de2Thanks @jerelmiller! - Create mechanism to add experimental features to Apollo Client#12927
96b531fThanks @jerelmiller! - EnsureLocalStatedoesn't try to read from the cache when using ano-cachefetch policy.#12927
bb8ed7bThanks @jerelmiller! - Ensure an error is thrown when@streamis detected and anincrementalDeliveryhandler is not configured.#13053
23ca0baThanks @phryneas! - Use memoized observable mapping when usingwatchFragment,useFragmentoruseSuspenseFragment.#12927
44706a2Thanks @jerelmiller! - Add helper typeQueryRef.ForQuery<TypedDocumentNode>#13082
c257418Thanks @phryneas! - PassstreamInfothrough result extensions as aWeakRef.#12927
4631175Thanks @jerelmiller! - Fix theDefer20220824Handler.SubsequentResulttype to match theFormattedSubsequentIncrementalExecutionResulttype ingraphql@17.0.0-alpha.2.#12927
96b531fThanks @jerelmiller! - Warn when using ano-cachefetch policy without a local resolver defined.no-cachequeries do not read or write to the cache which meantno-cachequeries are silently incomplete when the@clientfield value was handled by a cachereadfunction.#12927
5776ea0Thanks @jerelmiller! - Update theacceptheader used with theGraphQL17Alpha9Handlertomultipart/mixed;incrementalSpec=v0.2to ensure the newest incremental delivery format is requested.#12927
45ebb52Thanks @jerelmiller! -DeepPartial<Array<TData>>now returnsArray<DeepPartial<TData>>instead ofArray<DeepPartial<TData | undefined>>.#13071
99ffe9aThanks @phryneas! -prerenderStatic: Expose return value ofrenderFunctionto userland, fixabortedproperty.This enables usage of
resumeAndPrerenderwith React 19.2.#13026
05eee67Thanks @jerelmiller! - Reduce the number of observables created bywatchFragmentby reusing existing observables as much as possible. This should improve performance when watching the same item in the cache multiple times after a cache update occurs.#13010
7627000Thanks @jerelmiller! - Handle@streampayloads that send multiple items in the same chunk when using theDefer20220824Handler.#13010
7627000Thanks @jerelmiller! - Handle an edge case with theDefer20220824Handlerwhere an error for a@streamitem that bubbles to the@streamboundary (such as an item returningnullfor a non-null array item) would write items from future chunks to the wrong array index. In these cases, the@streamfield is no longer processed and future updates to the field are ignored. This prevents runtime errors that TypeScript would otherwise not be able to catch.#13081
1e06ad7Thanks @jerelmiller! - Avoid callingmergefunctions more than once for the same incremental chunk.v4.0.13Compare Source
Patch Changes
#13094
9cbe2c2Thanks @phryneas! - Ensure thatcompactandmergeOptionspreserve symbol keys.This fixes an issue where the change introduced in 4.0.11 via #13049 would not
be applied if
defaultOptionsforwatchQuerywere declared.Please note that
compactandmergeOptionsare considered internal utilitiesand they might have similar behavior changes in future releases.
Do not use them in your application code - a change like this is not considered
breaking and will not be announced as such.
v4.0.12Compare Source
Patch Changes
#12884
d329790Thanks @phryneas! - Ensure thatPreloadedQueryRefinstances are unsubscribed when garbage collected#13069
9cad04aThanks @jerelmiller! - Truncate @stream arrays only on last chunk by defaultv4.0.11Compare Source
Patch Changes
#13050
8020829Thanks @phryneas! - Replace usage offindLastwith more backwards-compatible methods.#13049
05638deThanks @phryneas! - Fixes an issue where queries starting withskipTokenor lazy queries fromuseLazyQuerywere included inclient.refetchQueries()before they had been executed for the first time. While generally queries with astandbyfetchPolicyshould be included in refetch, these queries never hadvariablespassed in, so they should be excluded until they have run once and received their actual variables.These queries are now properly excluded from refetch operations until after their initial execution.
This change adds a new hidden option to
client.watchQuery,[variablesUnknownSymbol], which may be settruefor queries starting with afetchPolicyofstandby. It will only be applied when creating theObservableQueryinstance and cannot be changed later. This flag indicates that the query's variables are not yet known, and thus it should be excluded from refetch operations until they are.This option is not meant for everyday use and is intended for framework integrations only.
v4.0.10Compare Source
Patch Changes
af4acdcThanks @phryneas! - Fix memory leak #13036v4.0.9Compare Source
Patch Changes
8f3bc9bThanks @jerelmiller! - Fix an issue where switching from options withvariablestoskipTokenwithuseSuspenseQueryanduseBackgroundQuerywould create a newObservableQuery. This could cause unintended refetches wherevariableswere absent in the request when the query was referenced withrefetchQueries.v4.0.8Compare Source
Patch Changes
f6d0efaThanks @CarsonF! - Fix cache.modify() mapping readonly arrays to singular referencev4.0.7Compare Source
Patch Changes
5b4f36aThanks @jerelmiller! - Don't sendoperationTypein the payload sent byGraphQLWsLink.v4.0.6Compare Source
Patch Changes
3b0d89bThanks @phryneas! - Fix a problem withfetchMorewhere the loading state wouldn't reset if the result wouldn't result in a data update.v4.0.5Compare Source
Patch Changes
e2fc385Thanks @phryneas! - Fix an invariance type error in theMockedResponsetype.v4.0.4Compare Source
Patch Changes
db8a04bThanks @jerelmiller! -Configuration
📅 Schedule: (in timezone Etc/UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Renovate Bot.