-
-
Notifications
You must be signed in to change notification settings - Fork 310
Feedback for "Pagination" #2303
-
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>'.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1