-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mutation response is undefined, but shouldn't be #7754
Comments
@extjbhlego Happy to help but we'll need some more information. A runnable reproduction using either this repo or this CodeSandbox will help us debug the issue. |
@jcreighton - I've tried, but I cannot find a way to reproduce the problem locally. However, we keep getting reports from Sentry about this error, where TS throws because it tries to read the The Apollo Client typings says that there will always be a Therefore, our usage looks like the provided example, doing I'd gladly try to provide more info and a reproduction case, but I will need some pointers/ideas/direction about where to look or how to approach it. Any help is much appreciated. |
@extjbhlego Are you still experiencing this issue? If so, could you create a CodeSandbox with the mutation as closely aligned to how it is in your codebase? That could give us a clue as to what is happening. |
@jcreighton - Yes, unfortunately. I created a sandbox indicating our typical way of doing mutations here . It does not reproduce the error, but shows how we use mutations in callbacks, and index into Here is a (slightly censored) screenshot of the error Two examples from our codebase that throws the error:
I hope the above provides enough context for the problem, and if not, please let me know how I can help further demonstrate the issue 😄 |
@jcreighton - Eureka! 😄 Today, I accidentally stumbled across a way to reproduce the error. It turns out that it can be reproduced if you provide an I've set up an updated sandbox that produces the issue when you press the button: https://codesandbox.io/s/late-sound-ettg7?file=/src/App.js We have a default error handling function that displays a nice default error message for the user in the few cases where we don't handle errors explicitly, which we provide to the |
@jcreighton Can you give any estimate as to when we can expect this to land in a patch? :) Thanks |
Intended outcome:
Using Apollo Client and hooks, the typings tell me that the response from an operation will always be defined, but that
response.data
might not be. As such, we always useresponse.data?.something
when unwrapping the response.We use the built-in options for
onCompleted
andonError
, and as such, do not wrap our calls intry/catch
assuming that any failures in the request will propagate to theonError
callback.Actual outcome:
We get Sentry reports that says
TypeError: undefined is not an object (evaluating 'n.data')
How to reproduce the issue:
Versions
The text was updated successfully, but these errors were encountered: