@graphile-contrib/graphql-sse
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@graphile-contrib/graphql-sse

PostGraphile support for GraphQL over Server-Sent Events (SSE) powered by 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"
  • The client can use the X-GraphQL-Event-Stream header for SSE endpoint discovery

Getting started

Install

npm install --save graphql-sse @graphile-contrib/graphql-sse

or

yarn add graphql-sse @graphile-contrib/graphql-sse

Integrate the plugin

PostGraphile CLI

postgraphile \
  --plugins @graphile/graphql-sse \
  ...

PostGraphile library

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.

Package Sidebar

Install

npm i @graphile-contrib/graphql-sse

Weekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

21.5 kB

Total Files

6

Last publish

Collaborators

  • benjie
  • enisdenjo
  • mattbretl
  • stlbucket