Hi,
On the browser, I am trying to use Apollo cache like a state container; would like to write some state to a Cache field and then read from it. I get data from a non-GraphQL source and would like to add to Apollo client cache field object when I get them, and then read from the cache later.
Say I want to write updated: true
on a Cache field object called MyDetails: {}
. MyDetails doesn’t have updated
field in its schema definition. I update the Cache with writeFragment
, with updated: true
. And then I use readQuery to read MyDetails
from the cache… I can see that the writeFragment is working, but I can’t see updated
field upon readQuery… I used @client
directive in my query as well (like updated @client
, but it won’t pull l the data from the cache…
Do I need to define a type policy for the updated
field that I am adding to the cache? If yes, what should the type policy return for it, as it is not a derived data, it’s literally the data that I put in the cache.
PS. I don’t want to use reactive variables for this, non-GraphQL source will give me so much data to keep in relation to GraphQL fields, so I would like to keep them in the GraphQL cache under each field object.