Closed lukashambsch closed 4 years ago
You can see how we've done it here https://github.com/mbirkegaard/reason-apollo-hooks/commit/3a85c459c42f472a9b4e6a5c5254c259273178a1. Waiting for the API change to be done with before adding the PR.
The problem is indeed that optimisticResponse
doesn't have the right shape for apollo. The outermost type needs to be a mutation and you need to add __typename
fields for all the nested types.
The docs give this example
optimisticResponse: {
__typename: "Mutation",
updateComment: {
id: commentId,
__typename: "Comment",
content: commentContent
}
}
The easiest way of getting the shape of the object you need to supply to the underlying js is to fire the mutation and checking the network response in your dev tools. optimisticResponse
needs to be the same underlying shape as the js object at data.whateveryounamedyourmutation
in the response.
@mbirkegaard That helped a ton! I was able to get it working now. Thanks!
I'm trying to add support for
optimisticResponse
on mutations on this branch: https://github.com/lukashambsch/reason-apollo-hooks/tree/add-optimistic-response. I've added it and it doesn't seem to be working correctly because of missing__typename
attributes.I'm getting the following warnings only when using `optimisticResponse'.
Along w/
Missing field __typename
for each nested object within the type.Here is how I'm defining the
optimisticResponse
object when using it:Does anyone have any ideas on the possible source of the issue? Maybe my implementation of
optimisticResponse
is wrong?