graphql-subscriptions
graphql-over-http
Our great sponsors
graphql-subscriptions | graphql-over-http | |
---|---|---|
7 | 12 | |
1,575 | 357 | |
-0.1% | 2.8% | |
4.6 | 7.2 | |
2 months ago | 18 days ago | |
TypeScript | JavaScript | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
graphql-subscriptions
-
three ways to deploy a serverless graphQL API
graphql-yoga is built on other packages that provide functionality required for building a GraphQL server such as web server frameworks like express and apollo-server, GraphQL subscriptions with graphql-subscriptions and subscriptions-transport-ws, GraphQL engine & schema helpers including graphql.js and graphql-tools, and an interactive GraphQL IDE with graphql-playground.
-
Subscriptions and Live Queries - Real Time with GraphQL
The most common used (but not best maintained) library for such a PubSub engine in the GraphQL context is graphql-subscriptions. There are also adapters available for more distributed systems (where all GraphQL API replicas must be notified about the event) e.g. over Redis.
-
GraphQL over WebSockets
During that work, we created and merged the reference implementation into graphql-js and created two supporting libraries: graphql-subscriptions and subscriptions-transport-ws. Here is a talk with deep dive into all the details.
-
Using useSWR as an alternative to Subscriptions?
The Prisma / GraphQL-Yoga comes with Subscriptions, and this was the first thing I came across when my client asked for realtime updates. The implementation was quite difficult - took me a long time. Eventually, it was working locally, and in staging. However, when it came to the production environment, for some reason it just didn't work! This unfortunately ended up with a user losing an auction, which ultimately went to court etc.
-
GraphQL subscriptions not working consistently
There are also other solutions available: https://github.com/apollographql/graphql-subscriptions#pubsub-implementations
-
Build a chat app with GraphQL Subscriptions & TypeScript: Part 2
First, let's try to understand what PubSub is exactly. Apollo Server uses a publish-subscribe (pub/sub) model to track events that update subscriptions. The graphql-subscriptions library included in all apollo-server packages (including middleware integrations) provides a PubSub class as a basic in-memory event bus.
-
GraphQL the Simple Way, or: Don't Use Apollo
To add this, I can just expand the basic setup above. To do so, I do actually use a couple of small Apollo modules! Most can be picked and configured independently. For this case, graphql-subscriptions provides a little bit of pubsub logic that works within resolvers, and subscriptions-transport-ws integrates that into Express to handle the websockets themselves. Super helpful
graphql-over-http
-
Websocket with socket.io or GraphQL subscriptions
However, if you are doing GraphQL subscriptions over Server Sent Events (HTTP) (which is currently not part of the GraphQL over HTTP specification), the data flow is only from server to client. So each operation must be a separate request, which should be no problem when using HTTP/2, as the browser connection limit is not hit so fast (There are also workarounds to this if you cannot ise HTTP/2).
-
Announcing GraphQL Yoga 2.0!
GraphQL-spec, GraphQL-over-HTTP: guarantees your GraphQL API to work with all existing GraphQL clients (Apollo, Relay, URQL, and more).
-
The Anatomy of a GraphQL Request
Note: While GraphQL can be done over almost any protocol, this article focuses on the most commonly used protocol GraphQL over HTTP. However, most knowledge can be transferred to other protocols such as GraphQL over WebSockets or other more exotic ones.
-
GraphQL over SSE (Server-Sent Events)
graphql-sse is a reference implementation of the GraphQL over Server-Sent Events Protocol aiming to become a part of the GraphQL over HTTP standard.
-
GraphQL over WebSockets
With no further ado - I humbly introduce graphql-ws. A coherent, feature-full, zero-dependency, plug-n-play, lazy, simple, server and client implementation of the new, security first GraphQL over WebSocket Protocol with full support for all 3 GraphQL operations: Queries, Mutations and Subscriptions. The protocol aims to be standardised and become a part of GraphQL with the help of the foundation’s GraphQL over HTTP work group.
-
I need a little help implementing user online status tracking with Apollo/GraphQL.
Have you thought about using graphql-ws instead? It uses the new graphql-transport-ws protocol which also has an open RFC that is discussed in the GraphQL working Groups.
-
GraphQL Query and Mutation over Websockets
I suggest using libraries like https://github.com/enisdenjo/graphql-ws or https://www.npmjs.com/package/@benzene/ws since both of them implement a new spec of subscription that is very close to adoption (https://github.com/graphql/graphql-over-http/pull/140).
What are some alternatives?
uWebSockets.js - μWebSockets for Node.js back-ends :metal:
amplify-flutter - A declarative library with an easy-to-use interface for building Flutter applications on AWS.
graphql-redis-subscriptions - A graphql subscriptions implementation using redis and apollo's graphql-subscriptions
fastify-websocket - basic websocket support for fastify
subscriptions-transport-ws - :arrows_clockwise: A WebSocket client + server for GraphQL subscriptions
graphql-yoga - 🧘 Rewrite of a fully-featured GraphQL Server with focus on easy setup, performance & great developer experience. The core of Yoga implements WHATWG Fetch API and can run/deploy on any JS environment.
graphql-js - A reference implementation of GraphQL for JavaScript
express-graphql - Create a GraphQL HTTP server with Express.
graphql-sse - Zero-dependency, HTTP/1 safe, simple, GraphQL over Server-Sent Events Protocol server and client.
apollo-server - 🌍 Spec-compliant and production ready JavaScript GraphQL server that lets you develop in a schema-first way. Built for Express, Connect, Hapi, Koa, and more.
ws - Simple to use, blazing fast and thoroughly tested WebSocket client and server for Node.js
SWR - React Hooks for Data Fetching