React-apollo: Error when re-rendering a component with mutation using `options.client`

Created on 17 Nov 2017  路  2Comments  路  Source: apollographql/react-apollo

Intended outcome:

Re-rendering a component with a mutation using options.client should not throw an error.

Actual outcome:

Invariant Violation
The operation 'addPerson' wrapping 'Foo' is expecting a variable: 'person' but it was not found in the props passed to 'Apollo(Foo)'

How to reproduce the issue:

https://codesandbox.io/s/v57lv7275

When debugging I've found that GraphQL.prototype.componentWillReceiveProps fires and falls into the if (this.client !== client && this.client !== nextContext.client) { block which then calls this.updateQuery(nextProps) and then this.calculateOptions(props) from there. The operation.variables has length so it loops through and throws this error.

The error does not occur if I remove the mutation options.client.

Version

Most helpful comment

What happens with this bug ? Also occurs in react-apollo 1.4.15 on the same conditions

All 2 comments

What happens with this bug ? Also occurs in react-apollo 1.4.15 on the same conditions

Looks fine with updated dependencies https://codesandbox.io/s/98lz33wr0y

Was this page helpful?
0 / 5 - 0 ratings