Skip to content

onDone typing for data includes null | undefined #1317

Open
@P4sca1

Description

@P4sca1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions