Skip to content

errorPolicy is not defined on FetchMoreQueryOptions interface for fetchMore #12297

Closed
@dlin303

Description

@dlin303

Issue Description

The fetchMore function doesn't take in an errorPolicy in its FetchMoreQueryOptions:

export interface FetchMoreQueryOptions<TVariables, TData = any> {
/** {@inheritDoc @apollo/client!QueryOptionsDocumentation#query:member} */
query?: DocumentNode | TypedDocumentNode<TData, TVariables>;
/** {@inheritDoc @apollo/client!QueryOptionsDocumentation#variables:member} */
variables?: Partial<TVariables>;
context?: DefaultContext;
}

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).

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions