nexus-plugin-subscriptions
Contents
Installation
npm install nexus-plugin-subscriptions
Example Usage
import { use, server, log } from 'nexus';
import { PrismaClient } from 'nexus-plugin-prisma/client';
import { subscriptions } from 'nexus-plugin-subscriptions';
import { createContext } from './context';
const db = new PrismaClient();
use(
subscriptions({
ws: { server: server.raw.http, path: '/subscriptions' },
keepAlive: 10 * 1000,
onConnect: async (payload: Record<string, any>) => {
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