简体   繁体   中英

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 .

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

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM