Releases: apollographql/apollo-client
v3.8.0-rc.2
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
v3.8.0-rc.1
3.8.0-rc.1
Patch Changes
- #11071
4473e925a
Thanks @jerelmiller! - #10509 introduced some helpers for determining the type of operation for a GraphQL query. This imported theOperationTypeNode
from graphql-js which is not available in GraphQL 14. To maintain compatibility with graphql-js v14, this has been reverted to use plain strings.
v3.8.0-rc.0
3.8.0-rc.0
Minor Changes
-
#11058
89bf33c42
Thanks @phryneas! - (Batch)HttpLink: PropagateAbortError
s to the user when a user-providedsignal
is passed to the link. Previously, these links would swallow allAbortErrors
, potentially causing queries and mutations to never resolve. As a result of this change, users are now expected to handleAbortError
s when passing in a user-providedsignal
. -
#11040
125ef5b2a
Thanks @phryneas! -HttpLink
/BatchHttpLink
: Abort theAbortController
signal more granularly.
Before this change, whenHttpLink
/BatchHttpLink
created anAbortController
internally, the signal would always be.abort
ed after the request was completed. This could cause issues with Sentry Session Replay and Next.js App Router Cache invalidations, which just replayed the fetch with the same options - including the cancelledAbortSignal
.With this change, the
AbortController
will only be.abort()
ed by outside events,
not as a consequence of the request completing.
Patch Changes
-
#11053
c0ca70720
Thanks @phryneas! - AddSuspenseCache
as a lazy hidden property on ApolloClient.
This means thatSuspenseCache
is now an implementation details of Apollo Client
and you no longer need to manually instantiate it and no longer need to pass it
intoApolloProvider
.
Trying to instantiate aSuspenseCache
instance in your code will now throw an
error.Migration:
-import { SuspenseCache } from '@apollo/client'; -const suspenseCache = new SuspenseCache(); -<ApolloProvider client={client} suspenseCache={suspenseCache} />; +<ApolloProvider client={client} />;
v3.8.0-beta.7
3.8.0-beta.7
Minor Changes
-
#10994
2ebbd3abb
Thanks @phryneas! - Add .js file extensions to imports in src and dist/*/.d.ts -
#11045
9c1d4a104
Thanks @jerelmiller! - When changing variables back to a previously used set of variables, do not automatically cache the result as part of the query reference. Instead, dispose of the query reference so that theInMemoryCache
can determine the cached behavior. This means that fetch policies that would guarantee a network request are now honored when switching back to previously used variables. -
#10915
3a62d8228
Thanks @phryneas! - Changes how development-only code is bundled in the library to more reliably enable consuming bundlers to reduce production bundle sizes while keeping compatibility with non-node environments.
Patch Changes
-
#11026
b8d405eee
Thanks @phryneas! - Store React.Context instance mapped by React.createContext instance, not React.version.
UsingReact.version
can cause problems withpreact
, as multiple versions ofpreact
will all identify themselves as React17.0.2
. -
#11000
1d43ab616
Thanks @phryneas! - Useimport * as React
everywhere. This prevents an error when importing@apollo/client
in a React Server component. (see #10974) -
#11035
a3ab7456d
Thanks @jerelmiller! - Incrementally re-render deferred queries after callingrefetch
or settingskip
tofalse
to match the behavior of the initial fetch. Previously, the hook would not re-render until the entire result had finished loading in these cases.
v3.8.0-beta.6
3.8.0-beta.6
Patch Changes
-
#11027
e47cfd04e
Thanks @phryneas! - Prevents the DevTool installation warning to be turned into a documentation link. -
#11013
5ed2cfdaf
Thanks @alessbell! - Make private fieldsinFlightLinkObservables
andfetchCancelFns
protected in QueryManager in order to make types available in@apollo/experimental-nextjs-app-support
package when extending theApolloClient
class. -
#11032
6a4da900a
Thanks @jerelmiller! - Throw errors inuseSuspenseQuery
for errors returned in incremental chunks whenerrorPolicy
isnone
. This provides a more consistent behavior of theerrorPolicy
in the hook.Potentially breaking change
Previously, if you issued a query with
@defer
and relied onerrorPolicy: 'none'
to set theerror
property returned fromuseSuspenseQuery
when the error was returned in an incremental chunk, this error is now thrown. Switch theerrorPolicy
toall
to avoid throwing the error and instead return it in theerror
property. -
#11025
6092b6edf
Thanks @jerelmiller! -useSuspenseQuery
anduseBackgroundQuery
will now properly apply changes to its options between renders.
v3.7.17
v3.8.0-beta.5
3.8.0-beta.5
Patch Changes
-
#10999
c1904a78a
Thanks @phryneas! - Fix a bug inQueryReference
wherethis.resolve
orthis.reject
might be executed even ifundefined
. -
#11018
5618953f3
Thanks @jerelmiller! -useBackgroundQuery
now uses its own options type calledBackgroundQueryHookOptions
rather than reusingSuspenseQueryHookOptions
. -
#11010
1051a9c88
Thanks @alessbell! - Hide queryRef in a Symbol inuseBackgroundQuery
s return value. -
#10960
ee407ef97
Thanks @alessbell! - Adds support forreturnPartialData
andrefetchWritePolicy
options inuseBackgroundQuery
hook.
v3.8.0-beta.4
3.8.0-beta.4
Patch Changes
- #10940
1d38f128f
Thanks @jerelmiller! - Add support for theskip
option inuseBackgroundQuery
anduseSuspenseQuery
. Setting this option totrue
will avoid a network request.
v3.7.16
Patch Changes
-
#10806
cb1540504
Thanks @phryneas! - Fix a bug inPersistedQueryLink
that would cause it to permanently skip persisted queries after a 400 or 500 status code. -
#10807
b32369592
Thanks @phryneas! -PersistedQueryLink
will now also check for error codes inextensions
. -
#10982
b9be7a814
Thanks @sdeleur-sc! - UpdaterelayStylePagination
to avoid populatingstartCursor
when only a single cursor is present under theedges
field. Use that cursor only as theendCursor
. -
#10962
772cfa3cb
Thanks @jerelmiller! - RemoveuseGETForQueries
option inBatchHttpLink.Options
type since it is not supported.
Potentially breaking change in PersistedQueryLink
Previously, if the PersistedQueryLink
encountered a single 400
or 500
error, it would stop sending any persisted queries in the future. This allowed you to use the link even if a server had no support for persisted queries.
We have decided to change this behavior, so now the PersistedQueryLink
will only stop trying to send query hashes if the server responds with a PERSISTED_QUERY_NOT_SUPPORTED
error code as it was unclear whether a 400
or 500
status code was in fact because the server did not support persisted queries.
If you relied on the previous behaviour, maybe because you were communicating with a server that might or might not support persisted queries, but would return with a different kind of error, you can use the disable
option callback to override this behavior like this:
createPersistedQueryLink({
// ... other options ...
disable({ operation }){
const { response } = operation.getContext();
return (
response &&
response.status &&
(response.status === 400 || response.status === 500)
);
}
})
Alternatively, consider removing the link entirely when your server does not support persisted queries.
New Contributors
- @sdeleur-sc made their first contribution in #10982
v3.8.0-beta.3
3.8.0-beta.3
Minor Changes
-
#10895
e187866fd
Thanks @(author)! - Add generic type parameter for the entity modified incache.modify
. Improves
TypeScript type inference for that type's fields and values of those fields.Example:
cache.modify<Book>({ id: cache.identify(someBook), fields: { title: (title) => { // title has type `string`. // It used to be `any`. }, => { // author has type `Reference | Book["author"]`. // It used to be `any`. }, }, });
-
#10895
e187866fd
Thanks @Gelio! - Use unique opaque types for theDELETE
andINVALIDATE
Apollo cache modifiers.This increases type safety, since these 2 modifiers no longer have the
any
type.
Moreover, it no longer triggers the@typescript-eslint/no-unsafe-return
rule.
Patch Changes
-
#10951
2e833b2ca
Thanks @alessbell! - ImproveuseBackgroundQuery
type interface -
#10964
f33171506
Thanks @alessbell! - Fixes a bug inBatchHttpLink
that removed variables from all requests by default. -
#10968
b102390b2
Thanks @phryneas! - Use printed query for query deduplication. Cacheprint
calls for GraphQL documents to speed up repeated operations. -
#10969
525a9317a
Thanks @phryneas! - Slightly decrease bundle size and memory footprint ofSuspenseCache
by changing how cache entries are stored internally.