Query with `fetchPolicy: 'cache-only'` is not updatable via `updateQueries`
See original GitHub issueI have a query Sale
that I don’t want to initially fetch and a mutation OpenSale
with:
updateQueries: {
Sale: (prev, { mutationResult }) => console.log('test'),
},
Intended outcome: Console prints ‘test’
Actual outcome: Nothing happens
How to reproduce the issue:
Create a query with fetchPolicy: 'cache-only'
, try to update it in a mutation with updateQueries
.
I’m trying to upgrade to 1.0.2 from 0.8.6. Previously I had noFetch: true
and everything worked fine. Is it an expected behavior in 1.x or a bug?
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
Queries - Apollo GraphQL Docs
Setting a fetch policy. By default, the useQuery hook checks the Apollo Client cache to see if all the data you requested is...
Read more >React Apollo: Understanding Fetch Policy with useQuery
A cache-only query throws an error if the cache does not contain data ... still manually update this query with refetch and updateQueries....
Read more >Data Query Patterns for Apollo GraphQL client - Medium
network-only : This fetch policy will always make the request to the server and update the cache. Using this fetch policy will keep...
Read more >Queries - Vue Apollo
Fetching data involves executing query operations using standard GraphQL ... it will update the cache with the result data (depending on the fetch...
Read more >How to Query GraphQL - LogiCloud
This article shows how to fetch GraphQL data in React with the `useQuery` hook and attach the result to your UI. You'll also...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You’re right, we could check what you pass against the definition in the query. That might be useful for client-side updates. What we can’t actually check is if the variables are of the correct type in the place where you use them.
I don’t think we want to get into the variable coercion business, but it’s good to know that we could, if we wanted to 😀
@Dattya yeah, that would definitely explain it! Apollo doesn’t coerce any variables you give it. Since we don’t have the schema on the client, so we can’t even check if they fit the definition. I can see how that would be useful though, so I’m thinking about adding the option to put some more schema information in the client in the future to be able to do validation etc. with it.