graphql-compose / graphql-compose/graphql-compose-subscription-boilerplate

How to use graph-ws instead

Open
#3 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
11
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Hi,

Thanks for this project that simplifies the burden on how to setup subscription. My issue is that it relies on **subscriptions-transport-ws** which is deprecated to the benefit of https://the-guild.dev/blog/graphql-over-websockets as mentioned on their [npm page](https://www.npmjs.com/package/subscriptions-transport-ws):

> The subscriptions-transport-ws library is not being actively maintained. It is recommended that you use the graphql-ws library instead. For details read the GraphQL over WebSockets announcement.

So I'm struggling about how to get the **roots** of my gql schema from the object returned by `schemaComposer.buildSchema()`

> subscriptionServer.js

```
import ws from 'ws'; // yarn add ws
import { useServer } from 'graphql-ws/lib/use/ws';
const GraphQlSchema = require('./graphql').default

//redis must be running
const server = new ws.Server({
port: 4001,
path: '/subscribe',
});

useServer(
// from the previous step
{ schema: GraphQlSchema, roots: GraphQlSchema },
server
);

console.log('Listening to port 4001');
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.