简体   繁体   中英

Update react ui after graphql mutation in node js

I know if you make a mutation with graphql in the client side(react) you can use the refetchQueries to query the new updated list of (items) you have.

However if i were to make a mutation on node.js side, is it possible to update the ui after a mutation was made?

mutation function returns a Promise which when it resolves provides data :

SomeMutation({variables:{...}).then(data => ...)

also if you are using Mutation tag in react, the second parameter contains data, which updates automatically when you call the function. you can pass this as props to your component:

 <Mutation mutation={addServiceMutation}>
    {(addService, { data }) => ( ... )
 </Mutation>

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