0
votes

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?

1
you're probably looking for grpahQL subscriptions - xadm
On the frontend you mean or backend? - Alexander Munck Af Rosenschöld
both, it won't work if client wants to use sth not supported on server - xadm
The only thing im doing on the client side is to submit a form trough http, however the logic and mutation happens in the backend, and i think in this case the client wont know when these changes are done. I tried to query after the mutation on the backend but there was no visual change on the front-end - Alexander Munck Af Rosenschöld
not much effrot on client needed, only have to subscribe - subscription opens and keeps connection (f.e. websocket) to update on changes - did you read docs? search for any graphql chat tutorial - xadm

1 Answers

0
votes

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>