is it possible to generate typing for the cache object of apollo client? #10384
Unanswered
jingjiezhou2021
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I’m using
graphql-codegen
withapollo-client
. Everything works great except one thing:I tried to update cache after mutation, the
update
function ofclient.mutate
doesn’t have typings for thecache
parameter(more specifically it is ofApolloCache<any>
), I expected it to be typed based on the graphql schema so that i can modify the desired field in cache data very easily.Example:
You can access
cache
property on theclient
instance which has typeApolloCache<NormalizedCacheObject>
but this is not connected with graphql schema.Either way when you try to modify the fields in the cache data there is no typing specifying the fields, you will have to manually input the name of the field
I couldn’t find any mention of this in the docs
Questions:
cache
object?Beta Was this translation helpful? Give feedback.
All reactions