Skip to content

Commit a6c68fc

Browse files
Merge pull request #2156 from the-guild-org/feat/gql-subscriptions-envelop-support
feat(services/gql-subscription): allow custom `execute()` and `subscribe()` for other plugin systems
2 parents 0be21ef + 97db271 commit a6c68fc

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/graphql/lib/services/gql-subscription.service.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { execute, GraphQLSchema, subscribe } from 'graphql';
1+
import {
2+
execute as graphqlExecute,
3+
GraphQLSchema,
4+
subscribe as graphqlSubscribe,
5+
} from 'graphql';
26
import { GRAPHQL_TRANSPORT_WS_PROTOCOL, ServerOptions } from 'graphql-ws';
37
import { useServer } from 'graphql-ws/lib/use/ws';
48
import {
@@ -25,7 +29,7 @@ export type GraphQLWsSubscriptionsConfig = Partial<
2529
export type GraphQLSubscriptionTransportWsConfig = Partial<
2630
Pick<
2731
SubscriptionTransportWsServerOptions,
28-
'onConnect' | 'onDisconnect' | 'keepAlive'
32+
'onConnect' | 'onDisconnect' | 'onOperation' | 'keepAlive'
2933
>
3034
> & {
3135
path?: string;
@@ -38,6 +42,8 @@ export type SubscriptionConfig = {
3842

3943
export interface GqlSubscriptionServiceOptions extends SubscriptionConfig {
4044
schema: GraphQLSchema;
45+
execute?: typeof graphqlExecute;
46+
subscribe?: typeof graphqlSubscribe;
4147
path?: string;
4248
context?: ServerOptions['context'];
4349
}
@@ -70,6 +76,8 @@ export class GqlSubscriptionService {
7076

7177
private initialize() {
7278
const supportedProtocols = [];
79+
const { execute = graphqlExecute, subscribe = graphqlSubscribe } =
80+
this.options;
7381

7482
if ('graphql-ws' in this.options) {
7583
const graphqlWsOptions =

0 commit comments

Comments
 (0)