Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feedback for "Pagination" #2303

DzelmeRichards started this conversation in Docs Discussions
Discussion options

Hi
Could You, please, help me figure this out.
I am building an app in angular 15, using "apollo-angular": "^4.2.0" and "@apollo/client": "^3.0.0"
I have a search page, that searches my database. search results are displayed as infinite scroll. I have two functions getData and fechMore. Second function is called when user scrolls down. It works with fetchPolicy: 'network-only', but i need to use Apollo caching feature. Documentation is confusing for me. I would like Apollo to cache data and if same search occurs second time, the data to be loaded from cache. Also if user loads more data, it should be merged in cache with existing one. So all previously fetched data could be loaded from cache on second search event. Is that possible? Which approach would You recommend to achieve desired result?
Also I cant put updateQuery in
loadMore() {
this.feedQuery.fetchMore({
variables: {
offset: this.offset,
},
updateQuery: (prev, { fetchMoreResult }) => {
if (!fetchMoreResult) return prev;

 return Object.assign({}, prev, {
 feed: [...prev.feed, ...fetchMoreResult.feed],
 });
 },
});

}
}
I get an error
Argument of type '{ query: TypedDocumentNode<unknown, unknown>; variables: { input: SearchObj; cursor: string; }; updateQuery: (prev: any, { fetchMoreResult }: { fetchMoreResult: any; }) => any; }' is not assignable to parameter of type 'FetchMoreQueryOptions<unknown, MyQueryResponse>'.
Object literal may only specify known properties, and 'updateQuery' does not exist in type 'FetchMoreQueryOptions<unknown, QueryResponse>'.

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant
Converted from issue

This discussion was converted from issue #2040 on September 19, 2024 14:20.

AltStyle によって変換されたページ (->オリジナル) /