I'm trying to use writeFragment but running into the following issues:

My fragment does have __typename though:
client.writeFragment({
id: job._id,
fragment: gql`
fragment JobsStatusUpdate on Job {
__typename
status
}
`,
data: {
status: 2
},
});
And I also have addTypename: true in my ApolloClient options. Any idea what's going on?
The data you're writing is missing __typename. Just change it to this:
client.writeFragment({
id: job._id,
fragment: gql`
fragment JobsStatusUpdate on Job {
__typename
status
}
`,
data: {
status: 2,
__typename: 'Job',
},
});
Oh of course. For some reason I didn't realize you had to specify __typename in the data, that seems obvious in retrospect. Thanks!
Can this be added to the docs example?
https://www.apollographql.com/docs/react/advanced/caching.html#writequery-and-writefragment
In case somebody comes here and has nested fragments, make sure you have the corresponding nested __typename fields inside the data field.
Most helpful comment
Can this be added to the docs example?
https://www.apollographql.com/docs/react/advanced/caching.html#writequery-and-writefragment