Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

MutationFunction TypeScript type incorrect in react-components #3432

Closed
Mike-Gibson opened this issue Aug 30, 2019 · 1 comment · Fixed by #3458
Closed

MutationFunction TypeScript type incorrect in react-components #3432

Mike-Gibson opened this issue Aug 30, 2019 · 1 comment · Fixed by #3458
Assignees

Comments

@Mike-Gibson
Copy link

The type MutationFunction used in react-components returns a Promise<void | MutationFetchResult<TData>> which makes it hard to use the result without first checking the result is defined.

This was discussed in #2095 and a fix was made for react-hooks in #3334 but the issue still remains in react-components.

As far as I'm aware, it would make sense that the mutation function does not return void in both react-hooks and react-components.

The type is defined here:

export declare type MutationFunction<
TData = any,
TVariables = OperationVariables
> = (
options?: MutationFunctionOptions<TData, TVariables>
) => Promise<void | MutationFetchResult<TData>>;

This occurs in react-apollo 3.0.1.

@rerissondaniel
Copy link

+1

@hwillson hwillson self-assigned this Sep 4, 2019
hwillson added a commit that referenced this issue Sep 5, 2019
The resolved value of the returned `Promise` from a
`MutationFunction` cannot be `void`.

Fixes #3432.
hwillson added a commit that referenced this issue Sep 5, 2019
* Remove `void` from `MutationFunction` Promise return type

The resolved value of the returned `Promise` from a
`MutationFunction` cannot be `void`.

Fixes #3432.

* Changelog update
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants