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

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-59477cb7230d569ac49ecfea1fc944ce07cde014
3
+ ## 2.5.0-alpha-fd2d1e0d8e449617611fe942cb85652de6ab07c4
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
- function getGraphQLWSOptions(gwRuntime, onContext) {
2960
- async function onSubscribe(ctx, idOrMessage, paramsOrUndefined) {
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
+ };
2972
+ function getGraphQLWSOptions(yoga, onContext) {
2973
+ function onSubscribe(ctx, idOrMessage, paramsOrUndefined) {
2961
2974
  let params;
2962
2975
  if (typeof idOrMessage === "string") {
2963
2976
  if (paramsOrUndefined == null) {
@@ -2967,32 +2980,25 @@ 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: yoga.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;
2995
- return gwRuntime.getResultForParams(
3001
+ return yoga.getResultForParams(
2996
3002
  {
2997
3003
  params: context.params,
2998
3004
  request: context.request
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,8 +2955,21 @@ const useStaticFiles = ({
2955
2955
  };
2956
2956
  };
2957
2957
 
2958
- function getGraphQLWSOptions(gwRuntime, onContext) {
2959
- async function onSubscribe(ctx, idOrMessage, paramsOrUndefined) {
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
+ };
2971
+ function getGraphQLWSOptions(yoga, onContext) {
2972
+ function onSubscribe(ctx, idOrMessage, paramsOrUndefined) {
2960
2973
  let params;
2961
2974
  if (typeof idOrMessage === "string") {
2962
2975
  if (paramsOrUndefined == null) {
@@ -2966,32 +2979,25 @@ 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: yoga.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;
2994
- return gwRuntime.getResultForParams(
3000
+ return yoga.getResultForParams(
2995
3001
  {
2996
3002
  params: context.params,
2997
3003
  request: context.request
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-hive/gateway-runtime",
3
- "version": "2.5.0-alpha-59477cb7230d569ac49ecfea1fc944ce07cde014",
3
+ "version": "2.5.0-alpha-fd2d1e0d8e449617611fe942cb85652de6ab07c4",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",