Skip to content

Commit 9a84cea

Browse files
committed
document
1 parent 02d0524 commit 9a84cea

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

website/src/pages/docs/features/subscriptions.mdx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,30 @@ const network = Network.create(executeQueryOrMutation, executeSubscription)
371371

372372
## GraphQL over Server-Sent Events Protocol (via `graphql-sse`)
373373

374+
There are two different modes in [GraphQL over Server-Sent Events spec](https://github.com/enisdenjo/graphql-sse/blob/master/PROTOCOL.md).
375+
376+
### Distinct Connections Mode
377+
378+
GraphQL Yoga supports [GraphQL over Server-Sent Events spec](https://github.com/enisdenjo/graphql-sse/blob/master/PROTOCOL.md#distinct-connections-mode) only in "distinct connections mode" with the `legacySse: false` flag.
379+
380+
```ts filename="yoga.ts"
381+
import { createServer } from 'node:http'
382+
import { createYoga } from 'graphql-yoga'
383+
384+
const yogaApp = createYoga({
385+
// ...
386+
legacySse: false
387+
})
388+
```
389+
390+
<Callout>
391+
When you enable this, simple SSE recipes won't work because it changes the
392+
data events format. You should use refer to [`graphql-sse` client
393+
recipes](https://github.com/enisdenjo/graphql-sse#recipes).
394+
</Callout>
395+
396+
### Single Connection Mode
397+
374398
In case you want the subscriptions to be transported following the [GraphQL over Server-Sent Events Protocol](https://github.com/enisdenjo/graphql-sse/blob/master/PROTOCOL.md), you simply use the `@graphql-yoga/plugin-graphql-sse` plugin for GraphQL Yoga that exposes an additional endpoint (defaulting to `/graphql/stream`) used for [graphql-sse](https://github.com/enisdenjo/graphql-sse) clients.
375399

376400
The plugin will hijack the request from the `onRequest` hook and will use **all** envelop plugins provided.

0 commit comments

Comments
 (0)