GraphQL 订阅与 socket.io [英] GraphQL Subscriptions vs socket.io

查看:44
本文介绍了GraphQL 订阅与 socket.io的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试基于 websocket 制作实时应用程序并有两个选择.一个是 socket.io,另一个是 GraphQL Subscriptions.但很难找到它们的比较.

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?

推荐答案

Socket.IO 是一个能够在浏览器和服务器之间进行实时、双向和基于事件的通信的库.socket.io

Socket.IO is a library that enables real-time, bidirectional and event-based communication between the browser and the server. socket.io

GraphQL 订阅另一方面是一个允许客户端收听来自服务器的实时消息的概念.

GraphQL Subscriptions on another hand is a concept that allows clients to listen to real-time messages from the server.

所以基本上,GraphQL 订阅 是一个定义政策和的规范.允许 GraphQL 客户端和服务器实时通信的规则.要实现该功能,您可以使用 Socket.io 等实时工具.

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.

更多细节可以看:https://dgraph.io/docs/graphql/subscriptions/

这篇关于GraphQL 订阅与 socket.io的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆