apollo
apollo copied to clipboard
onDone typing for data includes null | undefined
Describe the bug
The typing of result.data in the onDone event hook (returned by useMutation and useQuery) is MyResult | null | undefined.
To Reproduce
const { mutate, onDone } = useMutation(MyTypedDocument)
onDone((result) => {
// The type of result.data is `MyResult | null | undefined`
})
Expected behavior
onDone: Event hook called when the mutation successfully completes.
I would expect that a successfull mutation / query cannot return null | undefined unless the GraphQL response type is nullable (which it is not in my case).
Versions vue: 2.6.14 vue-apollo: 4.0.0-alpha.16 @apollo/client: 3.5.8
I also have the same logic problem. But maybe that's intended?
That would imply that onDone is called when a response is not successful, which afaik is not the case.
I agree. I hope someone will see that and fix it :)