3.8.0-rc.2
Minor Changes
-
#11112
b4aefcfe9
Thanks @jerelmiller! - Adds support for askipToken
sentinel that can be used asoptions
inuseSuspenseQuery
anduseBackgroundQuery
to skip execution of a query. This works identically to theskip
option but is more type-safe and as such, becomes the recommended way to skip query execution. As such, theskip
option has been deprecated in favor ofskipToken
.We are considering the removal of the
skip
option fromuseSuspenseQuery
anduseBackgroundQuery
in the next major. We are releasing with it now to make migration fromuseQuery
easier and makeskipToken
more discoverable.import { skipToken } from "@apollo/client"; const id: number | undefined; const { data } = useSuspenseQuery( query, id ? { variables: { id } } : skipToken );
Breaking change
Previously
useBackgroundQuery
would always return aqueryRef
whenever query execution was skipped. This behavior been updated to return aqueryRef
only when query execution is enabled. If initializing the hook with it skipped,queryRef
is now returned asundefined
.To migrate, conditionally render the component that accepts the
queryRef
as props.Before
function Parent() { const [queryRef] = useBackgroundQuery(query, skip ? skipToken : undefined); // ^? QueryReference<TData | undefined> return <Child queryRef={queryRef} />; } function Child({ queryRef, }: { queryRef: QueryReference<TData | undefined>; }) { const { data } = useReadQuery(queryRef); }
After
function Parent() { const [queryRef] = useBackgroundQuery(query, skip ? skipToken : undefined); // ^? QueryReference<TData> | undefined return queryRef ? <Child queryRef={queryRef} /> : null; } function Child({ queryRef }: { queryRef: QueryReference<TData> }) { const { data } = useReadQuery(queryRef); }
Patch Changes
-
#11086
0264fee06
Thanks @jerelmiller! - Fix an issue where a call torefetch
,fetchMore
, or changingskip
tofalse
that returned a result deeply equal to data in the cache would get stuck in a pending state and never resolve. -
#11115
78739e3ef
Thanks @phryneas! - Enforceexport type
for all type-level exports. -
#11103
e3d611daf
Thanks @caylahamann! - Fixes a bug inuseMutation
so thatonError
is called when an error is returned from the request witherrorPolicy
set to 'all' . -
#11083
f766e8305
Thanks @phryneas! - Adjust the rerender timing ofuseQuery
to more closely align withuseFragment
. This means that cache updates delivered to both hooks should trigger renders at relatively the same time. Previously, theuseFragment
might rerender much faster leading to some confusion. -
#11082
0f1cde3a2
Thanks @phryneas! - Restore Apollo Client 3.7getApolloContext
behaviour