@graphql-hive/gateway-runtime 2.5.0-rc-389a7c75fe7d3ab97a440fa356a38823e93abd9b → 2.5.0-rc-804105972c99ff73702f9a1261d6df0707de5e4a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @graphql-hive/gateway-runtime
2
2
 
3
- ## 2.5.0-rc-389a7c75fe7d3ab97a440fa356a38823e93abd9b
3
+ ## 2.5.0-rc-804105972c99ff73702f9a1261d6df0707de5e4a
4
4
  ### Minor Changes
5
5
 
6
6
 
@@ -17,6 +17,12 @@
17
17
  - Updated dependency [`@types/node@^25.0.0` ↗︎](https://www.npmjs.com/package/@types/node/v/25.0.0) (from `^24.10.1`, in `dependencies`)
18
18
 
19
19
 
20
+ - [#1804](https://github.com/graphql-hive/gateway/pull/1804) [`c913e6c`](https://github.com/graphql-hive/gateway/commit/c913e6cfec407d4d2da5b264d38047a9df8e09f0) Thanks [@ardatan](https://github.com/ardatan)! - Fixes for better support of the plugin system in WebSockets;
21
+
22
+ - Ensure `params: GraphQLParams` and `request: Request` exist in the context
23
+ - Invoke `onParams` and `onExecutionResult` hooks from plugins properly
24
+
25
+
20
26
  - [#1787](https://github.com/graphql-hive/gateway/pull/1787) [`a50d93a`](https://github.com/graphql-hive/gateway/commit/a50d93a0bc8f3c67de7449ad9102d3f3b60ea96a) Thanks [@enisdenjo](https://github.com/enisdenjo)! - Usage reporting clientInfo context inherits Hive Gateway context
21
27
 
22
28
  - Updated dependencies []:
package/dist/index.cjs CHANGED
@@ -2956,39 +2956,60 @@ const useStaticFiles = ({
2956
2956
  };
2957
2957
  };
2958
2958
 
2959
- function getGraphQLWSOptions(gwRuntime, onContext) {
2960
- return {
2961
- execute: (args) => args.rootValue.execute(args),
2962
- subscribe: (args) => args.rootValue.subscribe(args),
2963
- onSubscribe: async (ctx, idOrMessage, payloadOrUndefined) => {
2964
- let payload;
2965
- if (typeof idOrMessage === "string") {
2966
- payload = payloadOrUndefined;
2967
- } else {
2968
- payload = idOrMessage.payload;
2969
- }
2970
- const { schema, execute: execute2, subscribe: subscribe2, contextFactory, parse, validate } = gwRuntime.getEnveloped({
2971
- connectionParams: ctx.connectionParams,
2972
- waitUntil: gwRuntime.waitUntil,
2973
- ...await onContext(ctx)
2974
- });
2975
- const args = {
2976
- schema: schema || await gwRuntime.getSchema(),
2977
- operationName: payload.operationName,
2978
- document: parse(payload.query),
2979
- variableValues: payload.variables,
2980
- contextValue: await contextFactory(),
2981
- rootValue: {
2982
- execute: execute2,
2983
- subscribe: subscribe2
2984
- }
2985
- };
2986
- if (args.schema) {
2987
- const errors = validate(args.schema, args.document);
2988
- if (errors.length) return errors;
2959
+ const FAKE_DOCUMENT = {
2960
+ kind: graphql.Kind.DOCUMENT,
2961
+ definitions: [
2962
+ {
2963
+ kind: graphql.Kind.OPERATION_DEFINITION,
2964
+ operation: graphql.OperationTypeNode.SUBSCRIPTION,
2965
+ selectionSet: {
2966
+ kind: graphql.Kind.SELECTION_SET,
2967
+ selections: []
2989
2968
  }
2990
- return args;
2991
2969
  }
2970
+ ]
2971
+ };
2972
+ function getGraphQLWSOptions(yoga, onContext) {
2973
+ function onSubscribe(ctx, idOrMessage, paramsOrUndefined) {
2974
+ let params;
2975
+ if (typeof idOrMessage === "string") {
2976
+ if (paramsOrUndefined == null) {
2977
+ throw new Error("Payload is required in graphql-ws v6+");
2978
+ }
2979
+ params = paramsOrUndefined;
2980
+ } else {
2981
+ params = idOrMessage.payload;
2982
+ }
2983
+ return promiseHelpers.handleMaybePromise(
2984
+ () => onContext(ctx),
2985
+ (additionalContext) => ({
2986
+ // Relax this check https://github.com/enisdenjo/graphql-ws/blob/master/src/server.ts#L805
2987
+ // We don't need `schema` here as it is handled by the gateway runtime
2988
+ document: FAKE_DOCUMENT,
2989
+ contextValue: {
2990
+ connectionParams: ctx.connectionParams,
2991
+ waitUntil: yoga.waitUntil,
2992
+ params,
2993
+ ...additionalContext
2994
+ }
2995
+ // So we cast it to ExecutionArgs to satisfy the return type without `schema`
2996
+ })
2997
+ );
2998
+ }
2999
+ function handleRegularArgs(args) {
3000
+ const context = args.contextValue;
3001
+ return yoga.getResultForParams(
3002
+ {
3003
+ params: context.params,
3004
+ request: context.request
3005
+ },
3006
+ context
3007
+ );
3008
+ }
3009
+ return {
3010
+ execute: handleRegularArgs,
3011
+ subscribe: handleRegularArgs,
3012
+ onSubscribe
2992
3013
  };
2993
3014
  }
2994
3015
 
package/dist/index.d.cts CHANGED
@@ -899,6 +899,6 @@ declare function getProxyExecutor<TContext extends Record<string, any>>({ config
899
899
  instrumentation: () => Instrumentation$2 | undefined;
900
900
  }): Executor;
901
901
 
902
- declare function getGraphQLWSOptions<TContext extends Record<string, any>, E>(gwRuntime: GatewayRuntime<TContext>, onContext: (ctx: Context<ConnectionInitMessage['payload'], E>) => MaybePromise<Record<string, unknown>>): ServerOptions<ConnectionInitMessage['payload'], E>;
902
+ declare function getGraphQLWSOptions<TContext extends Record<string, any>, E>(yoga: YogaServerInstance<Record<string, any>, TContext>, onContext: (ctx: Context<ConnectionInitMessage['payload'], E>) => MaybePromise<Record<string, unknown>>): ServerOptions<ConnectionInitMessage['payload'], E>;
903
903
 
904
904
  export { type GatewayConfig, type GatewayConfigBase, type GatewayConfigContext, type GatewayConfigProxy, type GatewayConfigSchemaBase, type GatewayConfigSubgraph, type GatewayConfigSupergraph, type GatewayContext, type GatewayGraphOSManagedFederationOptions, type GatewayGraphOSOptions, type GatewayGraphOSReportingOptions, type GatewayHiveCDNOptions, type GatewayHivePersistedDocumentsOptions, type GatewayHiveReportingOptions, type GatewayPlugin, type GatewayRuntime, type Instrumentation, type OnCacheDeleteHook, type OnCacheDeleteHookEventPayload, type OnCacheDeleteHookResult, type OnCacheErrorHook, type OnCacheErrorHookPayload, type OnCacheGetHook, type OnCacheGetHookEventPayload, type OnCacheGetHookResult, type OnCacheHitHook, type OnCacheHitHookEventPayload, type OnCacheMissHook, type OnCacheSetHook, type OnCacheSetHookEventPayload, type OnCacheSetHookResult, type OnFetchHook, type OnFetchHookDone, type OnFetchHookDonePayload, type OnFetchHookPayload, type ProgressiveOverrideHandler, type PropagateHeadersOpts, type StaticFilesOpts, type UnifiedGraphConfig, createGatewayRuntime, createLoggerFromLogging, getGraphQLWSOptions, getProxyExecutor, getRetryInfo, isRetryExecutionRequest, useCustomFetch, usePropagateHeaders, useStaticFiles, useUpstreamRetry, useUpstreamTimeout };
package/dist/index.d.ts CHANGED
@@ -899,6 +899,6 @@ declare function getProxyExecutor<TContext extends Record<string, any>>({ config
899
899
  instrumentation: () => Instrumentation$2 | undefined;
900
900
  }): Executor;
901
901
 
902
- declare function getGraphQLWSOptions<TContext extends Record<string, any>, E>(gwRuntime: GatewayRuntime<TContext>, onContext: (ctx: Context<ConnectionInitMessage['payload'], E>) => MaybePromise<Record<string, unknown>>): ServerOptions<ConnectionInitMessage['payload'], E>;
902
+ declare function getGraphQLWSOptions<TContext extends Record<string, any>, E>(yoga: YogaServerInstance<Record<string, any>, TContext>, onContext: (ctx: Context<ConnectionInitMessage['payload'], E>) => MaybePromise<Record<string, unknown>>): ServerOptions<ConnectionInitMessage['payload'], E>;
903
903
 
904
904
  export { type GatewayConfig, type GatewayConfigBase, type GatewayConfigContext, type GatewayConfigProxy, type GatewayConfigSchemaBase, type GatewayConfigSubgraph, type GatewayConfigSupergraph, type GatewayContext, type GatewayGraphOSManagedFederationOptions, type GatewayGraphOSOptions, type GatewayGraphOSReportingOptions, type GatewayHiveCDNOptions, type GatewayHivePersistedDocumentsOptions, type GatewayHiveReportingOptions, type GatewayPlugin, type GatewayRuntime, type Instrumentation, type OnCacheDeleteHook, type OnCacheDeleteHookEventPayload, type OnCacheDeleteHookResult, type OnCacheErrorHook, type OnCacheErrorHookPayload, type OnCacheGetHook, type OnCacheGetHookEventPayload, type OnCacheGetHookResult, type OnCacheHitHook, type OnCacheHitHookEventPayload, type OnCacheMissHook, type OnCacheSetHook, type OnCacheSetHookEventPayload, type OnCacheSetHookResult, type OnFetchHook, type OnFetchHookDone, type OnFetchHookDonePayload, type OnFetchHookPayload, type ProgressiveOverrideHandler, type PropagateHeadersOpts, type StaticFilesOpts, type UnifiedGraphConfig, createGatewayRuntime, createLoggerFromLogging, getGraphQLWSOptions, getProxyExecutor, getRetryInfo, isRetryExecutionRequest, useCustomFetch, usePropagateHeaders, useStaticFiles, useUpstreamRetry, useUpstreamTimeout };
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ import { AsyncDisposableStack } from '@whatwg-node/disposablestack';
23
23
  export * from '@whatwg-node/disposablestack';
24
24
  import { handleMaybePromise, iterateAsync } from '@whatwg-node/promise-helpers';
25
25
  import { useCookies } from '@whatwg-node/server-plugin-cookies';
26
- import { print, visit, visitWithTypeInfo, getArgumentValues, getNamedType, isIntrospectionType, isListType, isCompositeType, getOperationAST, isSchema, parse, buildSchema, buildASTSchema } from 'graphql';
26
+ import { print, visit, visitWithTypeInfo, getArgumentValues, getNamedType, isIntrospectionType, isListType, isCompositeType, getOperationAST, isSchema, parse, buildSchema, buildASTSchema, Kind, OperationTypeNode } from 'graphql';
27
27
  import { isAsyncIterable as isAsyncIterable$1, useReadinessCheck, useExecutionCancellation, createYoga, chain, mergeSchemas } from 'graphql-yoga';
28
28
  import { DEFAULT_UPLINKS, fetchSupergraphSdlFromManagedFederation } from '@graphql-tools/federation';
29
29
  import { useApolloUsageReport } from '@graphql-yoga/plugin-apollo-usage-report';
@@ -2955,39 +2955,60 @@ const useStaticFiles = ({
2955
2955
  };
2956
2956
  };
2957
2957
 
2958
- function getGraphQLWSOptions(gwRuntime, onContext) {
2959
- return {
2960
- execute: (args) => args.rootValue.execute(args),
2961
- subscribe: (args) => args.rootValue.subscribe(args),
2962
- onSubscribe: async (ctx, idOrMessage, payloadOrUndefined) => {
2963
- let payload;
2964
- if (typeof idOrMessage === "string") {
2965
- payload = payloadOrUndefined;
2966
- } else {
2967
- payload = idOrMessage.payload;
2968
- }
2969
- const { schema, execute: execute2, subscribe: subscribe2, contextFactory, parse, validate } = gwRuntime.getEnveloped({
2970
- connectionParams: ctx.connectionParams,
2971
- waitUntil: gwRuntime.waitUntil,
2972
- ...await onContext(ctx)
2973
- });
2974
- const args = {
2975
- schema: schema || await gwRuntime.getSchema(),
2976
- operationName: payload.operationName,
2977
- document: parse(payload.query),
2978
- variableValues: payload.variables,
2979
- contextValue: await contextFactory(),
2980
- rootValue: {
2981
- execute: execute2,
2982
- subscribe: subscribe2
2983
- }
2984
- };
2985
- if (args.schema) {
2986
- const errors = validate(args.schema, args.document);
2987
- if (errors.length) return errors;
2958
+ const FAKE_DOCUMENT = {
2959
+ kind: Kind.DOCUMENT,
2960
+ definitions: [
2961
+ {
2962
+ kind: Kind.OPERATION_DEFINITION,
2963
+ operation: OperationTypeNode.SUBSCRIPTION,
2964
+ selectionSet: {
2965
+ kind: Kind.SELECTION_SET,
2966
+ selections: []
2988
2967
  }
2989
- return args;
2990
2968
  }
2969
+ ]
2970
+ };
2971
+ function getGraphQLWSOptions(yoga, onContext) {
2972
+ function onSubscribe(ctx, idOrMessage, paramsOrUndefined) {
2973
+ let params;
2974
+ if (typeof idOrMessage === "string") {
2975
+ if (paramsOrUndefined == null) {
2976
+ throw new Error("Payload is required in graphql-ws v6+");
2977
+ }
2978
+ params = paramsOrUndefined;
2979
+ } else {
2980
+ params = idOrMessage.payload;
2981
+ }
2982
+ return handleMaybePromise(
2983
+ () => onContext(ctx),
2984
+ (additionalContext) => ({
2985
+ // Relax this check https://github.com/enisdenjo/graphql-ws/blob/master/src/server.ts#L805
2986
+ // We don't need `schema` here as it is handled by the gateway runtime
2987
+ document: FAKE_DOCUMENT,
2988
+ contextValue: {
2989
+ connectionParams: ctx.connectionParams,
2990
+ waitUntil: yoga.waitUntil,
2991
+ params,
2992
+ ...additionalContext
2993
+ }
2994
+ // So we cast it to ExecutionArgs to satisfy the return type without `schema`
2995
+ })
2996
+ );
2997
+ }
2998
+ function handleRegularArgs(args) {
2999
+ const context = args.contextValue;
3000
+ return yoga.getResultForParams(
3001
+ {
3002
+ params: context.params,
3003
+ request: context.request
3004
+ },
3005
+ context
3006
+ );
3007
+ }
3008
+ return {
3009
+ execute: handleRegularArgs,
3010
+ subscribe: handleRegularArgs,
3011
+ onSubscribe
2991
3012
  };
2992
3013
  }
2993
3014
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-hive/gateway-runtime",
3
- "version": "2.5.0-rc-389a7c75fe7d3ab97a440fa356a38823e93abd9b",
3
+ "version": "2.5.0-rc-804105972c99ff73702f9a1261d6df0707de5e4a",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",