mercurius
Advanced tools
Comparing version 16.0.0 to 16.0.1
@@ -26,7 +26,19 @@ import { | ||
declare namespace mercurius { | ||
export interface PubSub { | ||
subscribe<TResult = any>(topics: string | string[]): Promise<Readable & AsyncIterableIterator<TResult>>; | ||
publish<TResult = any>(event: { topic: string; payload: TResult }, callback?: () => void): void; | ||
export interface PubSubTopics { | ||
[topic: string]: any; | ||
} | ||
export interface PubSub<TPubSubTopics extends PubSubTopics = PubSubTopics> { | ||
subscribe<TTopic extends Extract<keyof TPubSubTopics, string>>( | ||
topics: TTopic | TTopic[], | ||
): Promise<Readable & AsyncIterableIterator<TPubSubTopics[TTopic]>>; | ||
publish<TTopic extends Extract<keyof TPubSubTopics, string>>( | ||
event: { | ||
topic: TTopic; | ||
payload: TPubSubTopics[TTopic]; | ||
}, | ||
callback?: () => void, | ||
): void; | ||
} | ||
export interface MercuriusContext { | ||
@@ -33,0 +45,0 @@ app: FastifyInstance; |
{ | ||
"name": "mercurius", | ||
"version": "16.0.0", | ||
"version": "16.0.1", | ||
"description": "Fastify GraphQL adapter with subscription support", | ||
@@ -42,3 +42,3 @@ "main": "index.js", | ||
"eslint": "^9.9.1", | ||
"fastify": "^5.0.0-alpha.4", | ||
"fastify": "^5.0.0", | ||
"graphql": "^16.0.0", | ||
@@ -45,0 +45,0 @@ "graphql-tag": "^2.12.6", |
@@ -2697,3 +2697,3 @@ 'use strict' | ||
const ws = new WebSocket(`ws://127.0.0.1:${fastify.server.address().port}/graphql`, 'graphql-ws') | ||
const ws = new WebSocket(`ws://localhost:${fastify.server.address().port}/graphql`, 'graphql-ws') | ||
@@ -2700,0 +2700,0 @@ await once(ws, 'open') |
@@ -401,3 +401,3 @@ /* eslint-disable @typescript-eslint/no-unused-expressions */ | ||
async () => { | ||
const subscription = await app.graphql.pubsub.subscribe<{ newNotification: string }>('topic') | ||
const subscription = await app.graphql.pubsub.subscribe('topic') | ||
@@ -404,0 +404,0 @@ subscription.on('data', (chunk) => { |
631423
19069