Major Changes
-
#12576
a92ff78
Thanks @jerelmiller! - Thecache
andforceFetch
properties are no longer available on context when callingoperation.getContext()
.cache
can be accessed through theoperation
withoperation.client.cache
instead.forceFetch
has been replaced withqueryDeduplication
which specifies whetherqueryDeduplication
was enabled for the request or not. -
#12576
a92ff78
Thanks @jerelmiller! -ApolloLink.execute
now requires a third argument which provides theclient
that initiated the request to the link chain. If you useexecute
directly, add a third argument with aclient
property:ApolloLink.execute(link, operation, { client }); // or if you import the `execute` function directly: execute(link, operation, { client });
-
#12566
ce4b488
Thanks @jerelmiller! - Don'tbroadcastQueries
when a query is torn down.
Minor Changes
-
#12576
a92ff78
Thanks @jerelmiller! - Provide an extension to define types forcontext
passed to the link chain. To define your own types, use declaration merging to add properties to theDefaultContext
type.// @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.ContextOptions
BatchHttpLink.ContextOptions
-
#12576
a92ff78
Thanks @jerelmiller! - Add aclient
property to theoperation
passed to the link chain. Thisclient
is set as theclient
making the request to the link chain.
Patch Changes
-
#12574
0098ec9
Thanks @jerelmiller! - Exportgql
from the@apollo/client/react
entrypoint. -
#12572
3dc50e6
Thanks @jerelmiller! - AdjustuseMutation
types 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 returnedmutate
function. Providing required variables touseMutation
will make them optional in the returnedmutate
function.