Using GraphQL Code Generator with React with hooks, I'm trying to update the Apollo cache after a mutation, following the example in the Apollo docs:
const [addName] = useAddNameMutation({
update(cache, {data: {addName}}) {
const {names} = cache.readQuery({query: GET_NAMES}); // Property 'names' does not exist on type '{ names: any; } | null'.
cache.writeQuery({
query: GET_NAMES,
data: {names: names.concat([addName])},
});
},
});
However, I get Property 'names' does not exist on type '{ names: any; } | null'.
on the destructured query variable.
What am I doing wrong?
Thanks in advance.