Authors GraphQL subscription resolver test suites over graphql-ws (WebSocket) and graphql-sse (Server-Sent Events) transports: subscribe to event streams via the async-iterator API, assert emitted data shape and sequence, verify connection lifecycle and protocol close codes, and validate auth-on-connect (connectionParams / authenticate callback) plus resolver-level pubsub trigger logic. Use for real-time subscription operations; not for queries or mutations - for those use apollo-server-tests, graphql-yoga-tests, or mercurius-tests.
75
94%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Both transports expose an identical async-iterator surface via client.iterate(),
so the same test patterns are portable once the server is up.
Per the-guild.dev/graphql/ws/get-started:
import { useServer } from 'graphql-ws/use/ws';
import { WebSocketServer } from 'ws';
import { schema } from './schema';
export function startWsServer(port = 0) {
const wss = new WebSocketServer({ port });
const dispose = useServer({ schema }, wss);
return { wss, dispose };
}Use port: 0 so the OS assigns a free port - parallel-test safe.
Per the-guild.dev/graphql/sse/get-started:
import { createServer } from 'http';
import { createHandler } from 'graphql-sse/lib/use/http';
import { schema } from './schema';
export function startSseServer() {
const handler = createHandler({ schema });
const server = createServer((req, res) => {
if (req.url === '/graphql/stream') return handler(req, res);
res.writeHead(404).end();
});
server.listen(0);
const { port } = server.address() as { port: number };
return { server, url: `http://localhost:${port}/graphql/stream` };
}