GCG: optimistic update throws type error when returning partial data #2320
-
I'm trying to implement an optimistic update, updating the the phase of a projectInfluencer. In this schema, mutation UpdateProjectInfluencerPhase($params: UpdateProjectInfluencerInput!) {
updateProjectInfluencer(params: $params) {
projectInfluencer {
id
projectPhase {
id
}
}
}
}
const optimistic: GraphCacheOptimisticUpdaters = {
updateProjectInfluencer: (variables, _cache, _info) => ({
__typename: 'UpdateProjectInfluencerPayload',
projectInfluencer: {
__typename: 'ProjectInfluencer',
id: variables.params.id,
projectPhase: {
__typename: 'ProjectPhase',
id: variables.params.projectPhaseId,
},
},
}),
}; I think because the urql version & exchanges: {
"@graphql-codegen/typescript-urql-graphcache": "^2.2.6",
"@urql/exchange-graphcache": "^4.3.6",
"urql": "^2.1.3",
}
Let me know if this should be raised in the graphql-codegen repo instead |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Isn't the top typename a Mutation? I don't think it's mandatory but that seems a bit off. What is the exception you are getting? Edit sorry I thought with throw you meant a js err Yes the types could be off for that one, I think it will be quite hard to remedy this one |
Beta Was this translation helpful? Give feedback.
-
I encountered the same issue. The problems seems to be that
Is there any reason you would not want the child entities to be partial? |
Beta Was this translation helpful? Give feedback.
Isn't the top typename a Mutation? I don't think it's mandatory but that seems a bit off. What is the exception you are getting? Edit sorry I thought with throw you meant a js err
Yes the types could be off for that one, I think it will be quite hard to remedy this one