I am following Ben Awad's "Fullstack React GraphQL TypeScript Tutorial" on youtube. It is a few years old, so I am scrambling to modify the code to work with updated packages, specifically here urql-graphcache.
If you are also following along, I'm near the 7:48 time mark.
I read through the documentation about the cache.resolve() method.
These are the examples from the docs
// This may resolve a link:
cache.resolve({ __typename: 'Query' }, 'todo', { id: 1 }); // 'Todo:1'
// This may also resolve records / scalar values:
cache.resolve({ __typename: 'Todo', id: 1 }, 'id'); // 1
// You can also chain multiple calls to `cache.resolve`!
cache.resolve(cache.resolve({ __typename: 'Query' }, 'todo', { id: 1 }), 'id'); // 1
These examples do not explain the behavior I get in my app that happens to work for the tutorial.
//first resolve call
const res = cache.resolve("Query", "posts({"limit":10})") //Query.posts({"limit":10})
//second resolve call
const res2 = cache.resovle(res as Entity, 'posts') // [Post:1, Post:2, Post:3]
It seems like cache.resolve() is actually a wrapper for 2 fundamentally different functions. But why would it be like this?
What is the first cach.resolve() resolving? How is the result of the res act as an Entity?
Is there a way to structure the call so that I only need to call it once?