apollographql / apollo-client

:rocket:  A fully-featured, production ready caching GraphQL client for every UI framework and GraphQL server.
https://apollographql.com/client
MIT License
19.34k stars 2.66k forks source link

Type error returning `IGNORE` object when using a generic `TypedDocumentNode` mutation #11945

Closed sneyderdev closed 2 months ago

sneyderdev commented 2 months ago

Issue Description

There's a type error when returning the IGNORE sentinel object from optimisticResponse that is inferring from a TypedDocumentNode<>.

Given the following document: image

We get the following type error: image

I've checked the type definitions and it's fixed if we explicitly return an union type instead of only returning the inferred type. I created a PR #11944 changing this.

Link to Reproduction

https://codesandbox.io/p/sandbox/optimisticresponse-apollo-ts-error-mv34ws

Reproduction Steps

No response

@apollo/client version

3.10.8

phryneas commented 2 months ago

Good catch - answering in the PR :)

github-actions[bot] commented 2 months ago

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better.

github-actions[bot] commented 1 month ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. For general questions, we recommend using StackOverflow or our discord server.