question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Query with `fetchPolicy: 'cache-only'` is not updatable via `updateQueries`

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
helfercommented, May 4, 2017

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 😀

1reaction
helfercommented, May 4, 2017

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found