https://github.com/graphile-contrib/graphql-sse
PostGraphile support for GraphQL over Server-Sent Events (SSE) powered by graphql-sse
https://github.com/graphile-contrib/graphql-sse
graphile graphql postgraphile realtime server-sent-events sse subscriptions
Last synced: 7 months ago
JSON representation
PostGraphile support for GraphQL over Server-Sent Events (SSE) powered by graphql-sse
- Host: GitHub
- URL: https://github.com/graphile-contrib/graphql-sse
- Owner: graphile-contrib
- License: mit
- Created: 2021-12-03T08:16:49.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-04-15T09:11:41.000Z (almost 4 years ago)
- Last Synced: 2025-06-16T15:19:02.334Z (8 months ago)
- Topics: graphile, graphql, postgraphile, realtime, server-sent-events, sse, subscriptions
- Language: TypeScript
- Homepage: https://npm.im/@graphile-contrib/graphql-sse
- Size: 854 KB
- Stars: 15
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @graphile-contrib/graphql-sse
PostGraphile support for [GraphQL over Server-Sent Events (SSE)](https://github.com/enisdenjo/graphql-sse/blob/master/PROTOCOL.md) powered by [graphql-sse](https://github.com/enisdenjo/graphql-sse).
- Doesn't mess with the schema update stream on `eventSourceRoute`, both can exist on the same route
- `PUT` and `DELETE` methods are allowed through CORS on the `eventSourceRoute` in order to support the ["single connection mode"](https://github.com/enisdenjo/graphql-sse/blob/master/PROTOCOL.md#single-connection-mode)
- The client can use the `X-GraphQL-Event-Stream` header for SSE endpoint discovery
## Getting started
### Install
```bash
npm install --save graphql-sse @graphile-contrib/graphql-sse
```
or
```bash
yarn add graphql-sse @graphile-contrib/graphql-sse
```
### Integrate the plugin
#### PostGraphile CLI
```bash
postgraphile \
--plugins @graphile/graphql-sse \
...
```
#### PostGraphile library
```ts
import { postgraphile, makePluginHook } from 'postgraphile';
import GraphQLSSEPlugin from '@graphile-contrib/graphql-sse';
const postGraphileMiddleware = postgraphile(databaseUrl, 'app_public', {
pluginHook: makePluginHook([GraphQLSSEPlugin]),
eventStreamRoute: '/graphql/stream', // default
});
```
### Use the client
Connect to the specified `PostGraphileOptions.eventStreamRoute`.
For further usage inspiration, please consult the [`graphql-sse` readme](https://github.com/enisdenjo/graphql-sse#readme).