Major Changes
-
#12576
a92ff78Thanks @jerelmiller! - ThecacheandforceFetchproperties are no longer available on context when callingoperation.getContext().cachecan be accessed through theoperationwithoperation.client.cacheinstead.forceFetchhas been replaced withqueryDeduplicationwhich specifies whetherqueryDeduplicationwas enabled for the request or not. -
#12576
a92ff78Thanks @jerelmiller! -ApolloLink.executenow requires a third argument which provides theclientthat initiated the request to the link chain. If you useexecutedirectly, add a third argument with aclientproperty:ApolloLink.execute(link, operation, { client }); // or if you import the `execute` function directly: execute(link, operation, { client });
-
#12566
ce4b488Thanks @jerelmiller! - Don'tbroadcastQuerieswhen a query is torn down.
Minor Changes
-
#12576
a92ff78Thanks @jerelmiller! - Provide an extension to define types forcontextpassed to the link chain. To define your own types, use declaration merging to add properties to theDefaultContexttype.// @apollo-client.d.ts // This import is necessary to ensure all Apollo Client imports // are still available to the rest of the application. import "@apollo/client"; declare module "@apollo/client" { interface DefaultContext extends Record<string, any> { myProperty: string; } }
Links that provide context options can be used with this type to add those context types to
DefaultContext. For example, to add context options fromHttpLink, add the following code:import { HttpLink } from "@apollo/client"; declare module "@apollo/client" { interface DefaultContext extends HttpLink.ContextOptions { myProperty: string; } }
At this time, the following built-in links support context options:
HttpLink.ContextOptionsBatchHttpLink.ContextOptions
-
#12576
a92ff78Thanks @jerelmiller! - Add aclientproperty to theoperationpassed to the link chain. Thisclientis set as theclientmaking the request to the link chain.
Patch Changes
-
#12574
0098ec9Thanks @jerelmiller! - Exportgqlfrom the@apollo/client/reactentrypoint. -
#12572
3dc50e6Thanks @jerelmiller! - AdjustuseMutationtypes to better handle required variables. When required variables are missing, TypeScript will now complain if they are not provided either to the hook or the returnedmutatefunction. Providing required variables touseMutationwill make them optional in the returnedmutatefunction.