-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
fetchMore not using cache even with @client directive. ( fetchPolicy hardcoded to "no-cache" ) #8541
Comments
I think i misinterpreted the goal of I initially thought that if you used the But, i see now that
So there's no "issue"... BUT, it would be useful to make it work as i initially thought... if you flag a query field as @client we are indeed kinda saying that we want that field to be fetched locally... So |
Hey there! Query:
Hook: FieldPolicy:
FetchMore call:
some logs:
|
@ladrone-vincet what's the implementation of One thing i can say in case it helps you... the "read" method of the TypePolicy of fetchMore will always fetch the network. In my case that was my misinterpretation that lead me to the error/weird behaviour. |
That's not true.
It's definitely not as straight forward as I'm not using the
|
Im trying to implement pagination over client side data. No network. I have implemented some typePolicies to use a local array as source of data. When executing the query, everything works as espected, but when i call fetchMore the data comes empty instead of the "next page"...
Having this:
when calling this:
Intended outcome
especting data.getPeople.listOfPeople to have the extra data added to it,...
Actual outcome
data.getPeople.listOfPeople remains unchanged, looks the same as the first value returned by useQuery hook.
How to reproduce the issue:
Created this error scenario using the error template: https://github.com/P48L0/react-apollo-error-template
Code of the error case is here: https://github.com/P48L0/react-apollo-error-template/blob/main/src/index.jsx
When you click "load more" the name 'Sara Smith' should be added to the list... but it is not added.
Discussed in https://github.com/apollographql/apollo-client/discussions/8540
Originally posted by P48L0 July 26, 2021
hi, im using "@apollo/client": "^3.3.21" and, while working on the client side, i was using "@client" on query calls as a way to "mock" server responses definging typePolicies on the InMemoryCache object. This works as espected when executing the queries from the useQuery hooks. But...
... the problem starts when trying to test pagination. When calling fetchMore, the response always comes in empty. Looking at the source code, i see that the combinedOptions used by that method sets fetchPolicy to "no-cache" and there's no way to change that... i was initially thinking that the code would see the @client and go straight to the cache, but no... it's still not clear to me what is happening but one thing im sure is that the cache is not being hit at all.
The question: is there a way to test pagination (using fetchMore) with purely local data? What if i want to fetch more on local data? there's no way?
The text was updated successfully, but these errors were encountered: