0.12.0 • Published 5 months ago
@graphql-ez/plugin-websockets v0.12.0
@graphql-ez/plugin-websockets
Integration with:
- GraphQL over WebSocket Protocol - graphql-ws
- Legacy Support for subscriptions-transport-ws (using a fork called subscriptions-transport-ws-envelop)
Usage
import { ezWebSockets } from '@graphql-ez/plugin-websockets';
const ezApp = CreateApp({
ez: {
plugins: [
ezWebSockets('adaptive'),
// ...
],
},
// ...
});export type WebSocketOptions =
// If you enable both protocols, it will automatically adapt to the correct protocol based on the client
| {
subscriptionsTransport?:
| {
rootValue?: any;
validationRules?: readonly any[] | ((context: ValidationContext) => any)[];
onOperation?: Function;
onOperationComplete?: Function;
onDisconnect?: Function;
keepAlive?: number;
}
| boolean;
// Check https://github.com/enisdenjo/graphql-ws/blob/master/docs/interfaces/server.serveroptions.md
graphQLWS?: Omit<GraphQLWSOptions, 'schema' | 'execute' | 'subscribe' | 'context' | 'validate' | 'onSubscribe'> | boolean;
wsOptions?: {
verifyClient?:
| ((
info: {
origin: string;
secure: boolean;
req: IncomingMessage;
},
callback: (res: boolean, code?: number, message?: string, headers?: OutgoingHttpHeaders) => void
) => void)
| ((info: { origin: string; secure: boolean; req: IncomingMessage }) => boolean);
clientTracking?: boolean;
perMessageDeflate?: boolean | PerMessageDeflateOptions;
maxPayload?: number;
};
}
// Only use graphql-ws library protocol
| 'new'
// Only use legacy subscriptions-transport-ws protocol
| 'legacy'
// Automatically use the correct protocol based on the client, the default value
| 'adaptive';Next.js Compatibility
This plugin is not supported for Next.js, since it follows the serverless architecture, and Websockets are not supported in serverless.
If you really need websockets for Next.js, you can use libraries like fastify-nextjs to use Fastify as a custom server for Next.js.
0.12.0
5 months ago
0.11.3
2 years ago
0.11.1
3 years ago
0.11.2
3 years ago
0.11.0
3 years ago
0.10.5
3 years ago
0.10.3
4 years ago
0.10.4
4 years ago
0.10.1
4 years ago
0.10.2
4 years ago
0.10.0
4 years ago
0.9.3
4 years ago
0.9.2
4 years ago
0.9.1
4 years ago
0.9.0
4 years ago
0.8.0
4 years ago
0.7.0
4 years ago
0.6.1
4 years ago
0.6.0
4 years ago
0.5.0
4 years ago
0.4.2
4 years ago
0.4.1
4 years ago
0.4.0
4 years ago
0.3.0
4 years ago
0.2.0
4 years ago
0.1.3
4 years ago
0.1.2
4 years ago
0.1.1
4 years ago
0.1.0
4 years ago