Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback for “Pagination” #2040

Open
DzelmeRichards opened this issue Jun 20, 2023 · 0 comments
Open

Feedback for “Pagination” #2040

DzelmeRichards opened this issue Jun 20, 2023 · 0 comments

Comments

@DzelmeRichards
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant