Description
Issue Description
The fetchMore
function doesn't take in an errorPolicy
in its FetchMoreQueryOptions
:
apollo-client/src/core/watchQueryOptions.ts
Lines 159 to 165 in cfb1ecd
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 forfetchMore
, the shallow merge will succeed andfetchMore
will inherit theerrorPolicy
from the original query. - If
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 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