https://github.com/danielmahon/nexus-plugin-subscriptions
Nexus plugin to support GraphQL subscriptions
https://github.com/danielmahon/nexus-plugin-subscriptions
Last synced: about 1 year ago
JSON representation
Nexus plugin to support GraphQL subscriptions
- Host: GitHub
- URL: https://github.com/danielmahon/nexus-plugin-subscriptions
- Owner: danielmahon
- Created: 2020-05-08T19:38:59.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T05:21:03.000Z (over 3 years ago)
- Last Synced: 2025-03-27T09:40:51.739Z (over 1 year ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/nexus-plugin-subscriptions
- Size: 2.02 MB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nexus-plugin-subscriptions
**Contents**
- [Installation](#installation)
- [Example Usage](#example-usage)
- [Runtime Contributions](#runtime-contributions)
## Installation
```
npm install nexus-plugin-subscriptions
```
## Example Usage
```ts
// app.ts
import { use, server, log } from 'nexus';
import { PrismaClient } from 'nexus-plugin-prisma/client';
import { subscriptions } from 'nexus-plugin-subscriptions';
// Your context handler
import { createContext } from './context';
const db = new PrismaClient();
// Nexus plugins
use(
subscriptions({
ws: { server: server.raw.http, path: '/subscriptions' },
keepAlive: 10 * 1000,
onConnect: async (payload: Record) => {
log.info('client connected');
return await createContext(payload['authorization'], { db });
},
onDisconnect: () => {
log.info('client disconnected');
},
})
);
```
## Runtime Contributions
Provides your generated schema to `nexus-plugin-subscriptions`