Sébastien Dubois
Sébastien Dubois

Reputation: 999

Multiple Apollo mutations

I followed the Apollo documentation to provide two mutations (createUser then signInUser) on a single React component, but one mutation (the "outer" one - signInUser) is not accessible to my code (this.props.signInUser is not a function). Maybe my server-side-enabled setup is masking one mutation, but I don't see where. Help appreciated :)

See full code here.

EDIT: same issue when using compose, see code.

Upvotes: 0

Views: 2120

Answers (2)

Sébastien Dubois
Sébastien Dubois

Reputation: 999

It was caused by my apollo higher-order component which did more complex things than just calling Apollo's graphql (related to server-side rendering) and somehow must be masking properties. I bypassed this SSR behaviour for these mutations (not needed), see code.

Upvotes: 0

user4989825
user4989825

Reputation:

You just need to name the mutations when passing them into the component, otherwise they are ALL called mutate, and override one another.

(By using the props function)

Here's a full example with named mutations:

https://gist.github.com/Siyfion/a2e9626ed431f8ff91af2c9b8cba1d67

Upvotes: 3

Related Questions