Best pattern for sending data from client to server #109
-
We're using this library with apollo, so maybe this question makes more sense in the apollo forums. If we have a websocket connection open already and we want to send some data back to the server, does it make sense to make a graphql mutation call that would travel through the websocket connection? Or should we instead make it a subscription that immediately closes on the server side? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
That sounds like you would want to do a mutation. Subscriptions are more meant for subscribing to events instead of updating stuff. That's what mutations are for, as you are probably mutateing state. Websockets are just the transport of this protocol, so you can do all available operation types (subscription, mutations, and queries) via that transport. |
Beta Was this translation helpful? Give feedback.
That sounds like you would want to do a mutation. Subscriptions are more meant for subscribing to events instead of updating stuff. That's what mutations are for, as you are probably mutateing state.
Websockets are just the transport of this protocol, so you can do all available operation types (subscription, mutations, and queries) via that transport.