@graphql-hive/gateway-runtime 2.5.0-alpha-3080ee4ee71ae9f1280f6298a1fbd1814b73141d → 2.5.0-alpha-59477cb7230d569ac49ecfea1fc944ce07cde014

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-alpha-3080ee4ee71ae9f1280f6298a1fbd1814b73141d
3
+ ## 2.5.0-alpha-59477cb7230d569ac49ecfea1fc944ce07cde014
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) [`d55cefc`](https://github.com/graphql-hive/gateway/commit/d55cefc2819242fe1d5b77621b1f9ebfc546eba1) 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
@@ -2957,38 +2957,53 @@ const useStaticFiles = ({
2957
2957
  };
2958
2958
 
2959
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;
2960
+ async function onSubscribe(ctx, idOrMessage, paramsOrUndefined) {
2961
+ let params;
2962
+ if (typeof idOrMessage === "string") {
2963
+ if (paramsOrUndefined == null) {
2964
+ throw new Error("Payload is required in graphql-ws v6+");
2969
2965
  }
2970
- const { schema, execute: execute2, subscribe: subscribe2, contextFactory, parse, validate } = gwRuntime.getEnveloped({
2966
+ params = paramsOrUndefined;
2967
+ } else {
2968
+ params = idOrMessage.payload;
2969
+ }
2970
+ return {
2971
+ schema: await gwRuntime.getSchema(),
2972
+ document: {
2973
+ kind: "Document",
2974
+ definitions: [
2975
+ {
2976
+ kind: "OperationDefinition",
2977
+ operation: "subscription",
2978
+ selectionSet: {
2979
+ kind: "SelectionSet",
2980
+ selections: []
2981
+ }
2982
+ }
2983
+ ]
2984
+ },
2985
+ contextValue: {
2971
2986
  connectionParams: ctx.connectionParams,
2972
2987
  waitUntil: gwRuntime.waitUntil,
2988
+ params,
2973
2989
  ...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;
2989
2990
  }
2990
- return args;
2991
- }
2991
+ };
2992
+ }
2993
+ function handleRegularArgs(args) {
2994
+ const context = args.contextValue;
2995
+ return gwRuntime.getResultForParams(
2996
+ {
2997
+ params: context.params,
2998
+ request: context.request
2999
+ },
3000
+ context
3001
+ );
3002
+ }
3003
+ return {
3004
+ execute: handleRegularArgs,
3005
+ subscribe: handleRegularArgs,
3006
+ onSubscribe
2992
3007
  };
2993
3008
  }
2994
3009
 
package/dist/index.js CHANGED
@@ -2956,38 +2956,53 @@ const useStaticFiles = ({
2956
2956
  };
2957
2957
 
2958
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;
2959
+ async function onSubscribe(ctx, idOrMessage, paramsOrUndefined) {
2960
+ let params;
2961
+ if (typeof idOrMessage === "string") {
2962
+ if (paramsOrUndefined == null) {
2963
+ throw new Error("Payload is required in graphql-ws v6+");
2968
2964
  }
2969
- const { schema, execute: execute2, subscribe: subscribe2, contextFactory, parse, validate } = gwRuntime.getEnveloped({
2965
+ params = paramsOrUndefined;
2966
+ } else {
2967
+ params = idOrMessage.payload;
2968
+ }
2969
+ return {
2970
+ schema: await gwRuntime.getSchema(),
2971
+ document: {
2972
+ kind: "Document",
2973
+ definitions: [
2974
+ {
2975
+ kind: "OperationDefinition",
2976
+ operation: "subscription",
2977
+ selectionSet: {
2978
+ kind: "SelectionSet",
2979
+ selections: []
2980
+ }
2981
+ }
2982
+ ]
2983
+ },
2984
+ contextValue: {
2970
2985
  connectionParams: ctx.connectionParams,
2971
2986
  waitUntil: gwRuntime.waitUntil,
2987
+ params,
2972
2988
  ...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;
2988
2989
  }
2989
- return args;
2990
- }
2990
+ };
2991
+ }
2992
+ function handleRegularArgs(args) {
2993
+ const context = args.contextValue;
2994
+ return gwRuntime.getResultForParams(
2995
+ {
2996
+ params: context.params,
2997
+ request: context.request
2998
+ },
2999
+ context
3000
+ );
3001
+ }
3002
+ return {
3003
+ execute: handleRegularArgs,
3004
+ subscribe: handleRegularArgs,
3005
+ onSubscribe
2991
3006
  };
2992
3007
  }
2993
3008
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-hive/gateway-runtime",
3
- "version": "2.5.0-alpha-3080ee4ee71ae9f1280f6298a1fbd1814b73141d",
3
+ "version": "2.5.0-alpha-59477cb7230d569ac49ecfea1fc944ce07cde014",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",