apollo-client icon indicating copy to clipboard operation
apollo-client copied to clipboard

onCompleted type signature does not account for partial data

Open martinjlowm opened this issue 1 year ago • 1 comments

Issue Description

The current type signature of onCompleted assumes the result is truthy: https://github.com/apollographql/apollo-client/blob/main/src/react/types/types.ts#L244, but that is not the case if error policy is set to none.

I'd expect the following and be more defensive regardless of how the configuration is:

export interface BaseMutationOptions {
  ...
  onCompleted?: (data: Partial<TData> | null, clientOptions?: BaseMutationOptions) => void;
  ... 
} 

Link to Reproduction

N/A

Reproduction Steps

N/A

martinjlowm avatar Jan 05 '24 10:01 martinjlowm

Hi @martinjlowm 👋🏻 we're planning on tackling this and other typing issues in the upcoming 3.10 minor release. I'll leave this Issue open so you and anyone else who's interested can track progress :)

bignimbus avatar Jan 17 '24 03:01 bignimbus