I'm trying to make real-time application based on websocket and got two options. One is socket.io and the other is GraphQL Subscriptions. But it was hard to find comparison of those.
What can be standard to choose one of them and is there any performance difference?
Here's my comparison as I had the same situation.
GraphQL Subscriptions - Give updates when the data changes. It can triggered when a mutation takes place in your GraphQL server. This is great as it keeps your logic tightly coupled. However, in the use case of a "Chat" application. This isn't the best.
Socket.IO - Provides a 2 Way Event notification services. Therefore, you can send event from the clients without waiting on a GraphQL mutation to be executed. For example: "User A is Typing..." Or a User enters or leaves the conversation.
Socket.IO is a library that enables real-time, bidirectional and event-based communication between the browser and the server. socket.io
GraphQL Subscriptions on another hand is a concept that allows clients to listen to real-time messages from the server.
So basically, GraphQL Subscriptions is a specification that defines the policies & rules that allow GraphQL clients and servers to communicate in real-time. And to implement the feature, you can use real-time tools like Socket.io.
For more detail, you can take a look at: https://dgraph.io/docs/graphql/subscriptions/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With