You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, under the hood, if errorPolicy for fetchMore is specified, fetchMore will perform a shallow merge of its options with the original query, with the specified FetchMoreQueryOptions taking precedence.
We should expose the errorPolicy type in FetchMoreQueryOptions to remove ambiguity surrounding its behavior when using TypeScript.
Other notes:
If variables is included as an option for fetchMore, the shallow merge will succeed and fetchMore will inherit the errorPolicy from the original query.
If query is included as an option for fetchMore, the original query options will be disregarded (all options will revert to their default values).
Click 'Query' button to fire off original query. Click 'fetchMore' button to paginate with the 'fetchMore' call which respects the specified errorPolicy in its options. The current type definition of FetchMoreQueryOptions would have you think otherwise.
Note: that if you remove the 'errorPolicy' from fetchMore and specify the query option, the pagination call will fail as it no longer inherits the original errorPolicy: "all".
@apollo/client version
3.9.5
The text was updated successfully, but these errors were encountered:
dlin303
changed the title
errorPolicy is not defined on FetchMoreOptions interface for fetchMoreerrorPolicy is not defined on FetchMoreQueryOptions interface for fetchMoreJan 22, 2025
Issue Description
The
fetchMore
function doesn't take in anerrorPolicy
in itsFetchMoreQueryOptions
:apollo-client/src/core/watchQueryOptions.ts
Lines 159 to 165 in cfb1ecd
However, under the hood, if
errorPolicy
forfetchMore
is specified,fetchMore
will perform a shallow merge of its options with the original query, with the specifiedFetchMoreQueryOptions
taking precedence.We should expose the
errorPolicy
type inFetchMoreQueryOptions
to remove ambiguity surrounding its behavior when using TypeScript.Other notes:
variables
is included as an option forfetchMore
, the shallow merge will succeed andfetchMore
will inherit theerrorPolicy
from the original query.query
is included as an option forfetchMore
, the original query options will be disregarded (all options will revert to their default values).Discord discussion: https://discord.com/channels/1022972389463687228/1329263008542625804/1329263008542625804
Link to Reproduction
https://codesandbox.io/p/sandbox/repro-11612-forked-rmdvfd?file=%2Fsrc%2FApp.js
Reproduction Steps
Click 'Query' button to fire off original query. Click 'fetchMore' button to paginate with the 'fetchMore' call which respects the specified
errorPolicy
in its options. The current type definition ofFetchMoreQueryOptions
would have you think otherwise.Note: that if you remove the 'errorPolicy' from
fetchMore
and specify thequery
option, the pagination call will fail as it no longer inherits the originalerrorPolicy: "all"
.@apollo/client
version3.9.5
The text was updated successfully, but these errors were encountered: