Skip to content

variables are missing some properties from cache.inspectFields in cacheExchange #1107

Answered by kitten
mreza0100 asked this question in Q&A
Discussion options

You must be logged in to vote

I think you’re confusing variables with arguments here. A field can have arguments which is a field with a call signature basically: field(argument: true).

However variables are the dollar-prefixed signature that only the query itself accepts.

Luckily, queries don’t care about this. Basically what you’re trying to do in your updater is cachedData?.posts.unshift(realResult);. So you don’t even need to use the same query.

All that Graphcache cares about is the post’s ID and type name to match up items in the list as described here: https://formidable.com/open-source/urql/docs/graphcache/normalized-caching/

So your updater can also just use a smaller query that only updates:

posts(
  limit: …

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@mreza0100
Comment options

@kitten
Comment options

Answer selected by kitten
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants