graphql-ws VS react-relay

Compare graphql-ws vs react-relay and see what are their differences.


Coherent, zero-dependency, lazy, simple, GraphQL over WebSocket Protocol compliant server and client. (by enisdenjo)


Relay is a JavaScript framework for building data-driven React applications. (by facebook)
Our great sponsors
  • Appwrite - The Open Source Firebase alternative introduces iOS support
  • Scout APM - Less time debugging, more time building
  • SonarLint - Deliver Cleaner and Safer Code - Right in Your IDE of Choice!
graphql-ws react-relay
17 32
1,103 16,928
- 0.8%
9.0 9.9
10 days ago 8 days ago
TypeScript Rust
MIT License MIT License
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
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.


Posts with mentions or reviews of graphql-ws. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2022-04-27.
  • GraphQL Subscriptions: Why we use SSE/Fetch over Websockets
    2 projects | | 27 Apr 2022
    There is already a JavaScript implementation for server + client with support for multiplexing from the same maintainer of graphql-ws: graphql-sse
  • how it subscription work on the apollo server?
    3 projects | | 26 Apr 2022
    Actually WebSocket is not the only protocol for executing GraphQL subscriptions. There is also a graphql-over-sse protocol, which is much more lightweight, and uses Server Sent Events. A popular implementation of it is the graphql-sse library, which is maintained by the same person as graphql-ws. The setup and API of both libraries is pretty similar.
  • Advice on using graphql-ws with Apollo/React
    2 projects | | 25 Oct 2021
    That said, I feel so close to success that I can't quite give up. I am using graphql-ws as I understand this to be the new standard implementation of GraphQL Subscriptions. However, of course, Apollo subscriptions have not been updated to implement this. So, looking at the Recipes over on the graphql-ws documentation I have found the guide for using Apollo client. However as I am new to Apollo, it is using a lot of terms I am unfamiliar with.
  • GraphQL Subscriptions and Mikro-Orm in 2021
    2 projects | | 14 Oct 2021
    Okay but seriously, if you've fallen down the rabbit hole of Apollo docs pointing you towards one library (subscription-transport-ws) which then points you to another (graphql-ws) , and so on and so forth, then hopefully this helps pull you out.
  • How does a client know if the server managing its subscription goes offline? (Multiple instances)
    2 projects | | 23 Sep 2021
    The most common protocol used today for subscriptions is the Apollo websocket protocol.
  • Graphql Subscriptions w/o apollo
    1 project | | 15 Sep 2021
    GraphQL subscriptions are just web sockets. You can check graphql-ws package if you want something without Apollo dependency. Though I don't understand why you want to not depend on it in the first place.
  • GraphQL Tools V8 - Stitch Federation Services
    4 projects | | 29 Jul 2021
    New GraphQL-WS ✔️
  • Subscriptions and Live Queries - Real Time with GraphQL
    5 projects | | 29 Jul 2021
    The interesting thing is that we can use any transport for delivering the results to client. The most popular implementation (as mentioned before) is subscriptions-transport-ws. Unfortunately, since it is poorly maintained, the GraphQL Working Group came up with a new implementation over WebSockets, graphql-ws.
  • GraphQL over WebSockets
    9 projects | | 29 Jul 2021
    Okay, so, how do I use WebSockets to add support for the GraphQL subscription operation? Doing a basic Google search, you’d be faced with a single solution, namely subscriptions-transport-ws. Looking through the repository, checking recent comments, reading through the issues and open PRs - might have you notice the abundance of bugs and their security implications. A summary can be found here.
  • I need a little help implementing user online status tracking with Apollo/GraphQL.
    7 projects | | 10 Jun 2021
    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.


Posts with mentions or reviews of react-relay. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2022-05-20.
  • how to make a lsp in rust ?
    8 projects | | 20 May 2022
    The Relay VSCode extension (recently released to OSS!) uses the language server protocol to communicate with a Relay compiler process. You can view the code here.
  • Looking for a example with Relay GraphQL SSR
    2 projects | | 12 May 2022
    Hey fam! I am scouting an example repo with Relay GraphQL Client set up with Next.JS
  • GraphQL Is a Trap?
    18 projects | | 6 May 2022
    Checkout Relay.js:

    It does a lot of client-side caching for you. The documentation is atrocious though IMO. I'm not sure if there exists a similar framework for backend caching.

    18 projects | | 6 May 2022
    > Checkout Relay.js:

    Relay is a GraphQL client. That's the irrelevant side of caching, because that can be trivially implemented by an intern, specially given GraphQL's official copout of caching based on primary keys [1], and doesn't have any meaningful impact on the client's resources.

    The relevant side of caching is server-side caching: the bits of your system that allow it to fulfill results while skipping the expensive bits, like having to hit the database.


  • Render as You Fetch Pattern
    2 projects | | 2 May 2022
    Regarding React.Suspense, note that at time of this writing only two known libraries know how to integrate with Suspense: there are React Relay and SWR. And if so, it is these two that we will deal with here.
  • Generate schema.json with GraphiQL or GraphQL endpoint
    2 projects | | 28 Apr 2022
    I'm having issues creating a schema.json file that can be parsed with babel-relay-plugin without running into an error. Taking a look at the schema.json file included in relay's example folder, I tried to copy the query in GraphiQL but I can't seem to get it right. I'm using Laravel as the backend. Is this something I can accomplish through GraphiQL or sending a request to the GraphQL endpoint and saving the response?
  • Testing strategy on Relay + React
    1 project | | 28 Mar 2022
    I can see people mock Relay.createContainer to bypass Relay and merely test React Component. It leaves the Relay part uncovered and there is no way to drive this part by testing.
  • Hooks Considered Harmful
    8 projects | | 21 Mar 2022
    We use a thing called Relay ( to manage our querying, mutating, and state management.

    When you query data, it is cached locally in a shared data store that will automatically trigger re-renders of components that take in the data types as a dependency.

    You don’t have to write an update to the data, you query it and Relay updates all the underlying models in the local state cache.

    The data types are correlated to your components via GraphQL fragments which allows Relay to know what and when to update.

    Because all the values you are using in your component are already stateful, you end up using A LOT less hooks since most state updates will trigger and happen for you.

    It’s incredibly powerful once you get going with it.

    The downside is getting it to work properly with the type generation. It can be rather finicky and Facebook likes to rewrite the API out from under you every couple years.

  • How to type an exported RelayContainer
    1 project | | 15 Mar 2022
    I looked into the types exported by the "react-relay" package but ReactContainer doesn't seem to carry over Props.
  • Show HN: WAPM – WebAssembly Package Manager
    6 projects | | 2 Mar 2022

What are some alternatives?

When comparing graphql-ws and react-relay you can also consider the following projects:

subscriptions-transport-ws - :arrows_clockwise: A WebSocket client + server for GraphQL subscriptions

react-query - ⚛️ Hooks for fetching, caching and updating asynchronous data in React

apollo-client - :rocket:  A fully-featured, production ready caching GraphQL client for every UI framework and GraphQL server.

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.

SWR - React Hooks for Data Fetching

axios - Promise based HTTP client for the browser and node.js

urql - The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.

GraphQL Kotlin - Libraries for running GraphQL in Kotlin

graphql-helix - A highly evolved GraphQL HTTP Server 🧬

dataloader - DataLoader is a generic utility to be used as part of your application's data fetching layer to provide a consistent API over various backends and reduce requests to those backends via batching and caching.

ws - Simple to use, blazing fast and thoroughly tested WebSocket client and server for Node.js

esbuild - An extremely fast JavaScript and CSS bundler and minifier