@graphql-hive/gateway-runtime 2.5.0-alpha-33aaa56f5cf67f3277f867322ab9b7f35d4a7cde → 2.5.0-alpha-d9649dff14ca22b877d8ccc366274dedd5141c5b

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-33aaa56f5cf67f3277f867322ab9b7f35d4a7cde
3
+ ## 2.5.0-alpha-d9649dff14ca22b877d8ccc366274dedd5141c5b
4
4
  ### Minor Changes
5
5
 
6
6
 
package/dist/index.cjs CHANGED
@@ -2956,8 +2956,21 @@ const useStaticFiles = ({
2956
2956
  };
2957
2957
  };
2958
2958
 
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: []
2968
+ }
2969
+ }
2970
+ ]
2971
+ };
2959
2972
  function getGraphQLWSOptions(gwRuntime, onContext) {
2960
- async function onSubscribe(ctx, idOrMessage, paramsOrUndefined) {
2973
+ function onSubscribe(ctx, idOrMessage, paramsOrUndefined) {
2961
2974
  let params;
2962
2975
  if (typeof idOrMessage === "string") {
2963
2976
  if (paramsOrUndefined == null) {
@@ -2967,28 +2980,21 @@ function getGraphQLWSOptions(gwRuntime, onContext) {
2967
2980
  } else {
2968
2981
  params = idOrMessage.payload;
2969
2982
  }
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: {
2986
- connectionParams: ctx.connectionParams,
2987
- waitUntil: gwRuntime.waitUntil,
2988
- params,
2989
- ...await onContext(ctx)
2990
- }
2991
- };
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: gwRuntime.waitUntil,
2992
+ params,
2993
+ ...additionalContext
2994
+ }
2995
+ // So we cast it to ExecutionArgs to satisfy the return type without `schema`
2996
+ })
2997
+ );
2992
2998
  }
2993
2999
  function handleRegularArgs(args) {
2994
3000
  const context = args.contextValue;
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,8 +2955,21 @@ const useStaticFiles = ({
2955
2955
  };
2956
2956
  };
2957
2957
 
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: []
2967
+ }
2968
+ }
2969
+ ]
2970
+ };
2958
2971
  function getGraphQLWSOptions(gwRuntime, onContext) {
2959
- async function onSubscribe(ctx, idOrMessage, paramsOrUndefined) {
2972
+ function onSubscribe(ctx, idOrMessage, paramsOrUndefined) {
2960
2973
  let params;
2961
2974
  if (typeof idOrMessage === "string") {
2962
2975
  if (paramsOrUndefined == null) {
@@ -2966,28 +2979,21 @@ function getGraphQLWSOptions(gwRuntime, onContext) {
2966
2979
  } else {
2967
2980
  params = idOrMessage.payload;
2968
2981
  }
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: {
2985
- connectionParams: ctx.connectionParams,
2986
- waitUntil: gwRuntime.waitUntil,
2987
- params,
2988
- ...await onContext(ctx)
2989
- }
2990
- };
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: gwRuntime.waitUntil,
2991
+ params,
2992
+ ...additionalContext
2993
+ }
2994
+ // So we cast it to ExecutionArgs to satisfy the return type without `schema`
2995
+ })
2996
+ );
2991
2997
  }
2992
2998
  function handleRegularArgs(args) {
2993
2999
  const context = args.contextValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-hive/gateway-runtime",
3
- "version": "2.5.0-alpha-33aaa56f5cf67f3277f867322ab9b7f35d4a7cde",
3
+ "version": "2.5.0-alpha-d9649dff14ca22b877d8ccc366274dedd5141c5b",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",