Apollo-client: undefined is not an object (evaluating 'response.data')

Created on 22 Jun 2019  路  6Comments  路  Source: apollographql/apollo-client

I dont really have idea what is happening. the error is inside the apollo code.
this happens whenever i try to mutate in other words mutation never works for me. all of my Query works but mutation never

Actual outcome:

undefined is not an object (evaluating 'response.data')
- node_modules\react-apollo\react-apollo.cjs.js:483:32 in onMutationCompleted
- node_modules\react-apollo\react-apollo.cjs.js:440:42 in <unknown>
- node_modules\promise\setimmediate\core.js:37:14 in tryCallOne
- node_modules\promise\setimmediate\core.js:123:25 in <unknown>
- node_modules\react-native\Libraries\Core\Timers\JSTimers.js:152:14 in _callTimer
- node_modules\react-native\Libraries\Core\Timers\JSTimers.js:200:17 in _callImmediatesPass
- node_modules\react-native\Libraries\Core\Timers\JSTimers.js:464:30 in callImmediates
* [native code]:null in callImmediates
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:320:6 in __callImmediates
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:135:6 in <unknown>
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:297:10 in __guard
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:134:17 in flushedQueue
* [native code]:null in flushedQueue
* [native code]:null in callFunctionReturnFlushedQueue

How to reproduce the issue:

this is my mutation:

const test = gql`
  mutation Test($param: Int) {
    test(param: $param)
  }
`;

this is my mutation component in my render method:

 <Mutation mutation={test}>
               {(addPoi, { data }) => (
                    <Button
                      onPress={() => {
                        addPoi({variables: {param: 1})
                        }}>
                    </Button>
                  )
               }
</Mutation>

Versions

 "apollo-cache-inmemory": "^1.5.1",
    "apollo-client": "^2.5.1",
    "apollo-link-error": "^1.1.11",
    "apollo-link-http": "^1.5.14",
    "react-apollo": "^2.5.5",

All 6 comments

any response here? I searched through the internet but didnt find anything with the same problem

I had the same issue, the problem was in the Apollo Client setup.

Hi, same problem here. Queries are working fine, but the most basic mutation is failing to deliver a non-null response, even though the graphql endpoint and mutation works correctly when tested via the graphql portal, and the mutation is happening correctly on the backend. This seems like a really basic thing. Would really appreciate some input.

I had the same issue, the problem was in the Apollo Client setup.

What was the problem with the Apollo Client setup @mjasnikovs?

I had this problem due to an error in my apollo-link-error link - it seems any errors occurring in that handler will be silenced. You might add a try/catch block to find these...

Does anyone knows how to stringify the object of the access token?
<Button className="login-button" type="submit" color="primary" variant="contained" size="large" fullWidth onClick={async () => { const response = await mutate({ variables: this.state }); console.log(response); this.setState({accessToken: response.data.accessToken}) console.log(this.state.email); console.log(this.state.userId); console.log(this.state.accessToken); console.log(JSON.stringify(response.data.accessToken)); this.context.login("a", "a"); }}> Sign In </Button>

Was this page helpful?
0 / 5 - 0 ratings