@graphql-tools/executor 1.3.7 → 1.3.8

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.
@@ -390,6 +390,7 @@ function buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path) {
390
390
  rootValue: exeContext.rootValue,
391
391
  operation: exeContext.operation,
392
392
  variableValues: exeContext.variableValues,
393
+ signal: exeContext.signal,
393
394
  };
394
395
  }
395
396
  exports.CRITICAL_ERROR = 'CRITICAL_ERROR';
@@ -501,7 +502,7 @@ function getStreamValues(exeContext, fieldNodes, path) {
501
502
  async function completeAsyncIteratorValue(exeContext, itemType, fieldNodes, info, path, iterator, asyncPayloadRecord) {
502
503
  exeContext.signal?.addEventListener('abort', () => {
503
504
  iterator.return?.();
504
- });
505
+ }, { once: true });
505
506
  const errors = asyncPayloadRecord?.errors ?? exeContext.errors;
506
507
  const stream = getStreamValues(exeContext, fieldNodes, path);
507
508
  let containsPromise = false;
@@ -1191,7 +1192,7 @@ function yieldSubsequentPayloads(exeContext) {
1191
1192
  exeContext.signal?.addEventListener('abort', () => {
1192
1193
  isDone = true;
1193
1194
  reject(exeContext.signal?.reason);
1194
- });
1195
+ }, { once: true });
1195
1196
  });
1196
1197
  async function next() {
1197
1198
  if (isDone) {
@@ -1240,7 +1241,7 @@ function yieldSubsequentPayloads(exeContext) {
1240
1241
  async throw(error) {
1241
1242
  await returnStreamIterators();
1242
1243
  isDone = true;
1243
- return Promise.reject(error);
1244
+ throw error;
1244
1245
  },
1245
1246
  async [disposablestack_1.DisposableSymbols.asyncDispose]() {
1246
1247
  await returnStreamIterators();
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executorFromSchema = void 0;
3
4
  exports.normalizedExecutor = normalizedExecutor;
4
5
  const graphql_1 = require("graphql");
5
6
  const value_or_promise_1 = require("value-or-promise");
7
+ const utils_1 = require("@graphql-tools/utils");
6
8
  const execute_js_1 = require("./execute.js");
7
9
  function normalizedExecutor(args) {
8
10
  const operationAST = (0, graphql_1.getOperationAST)(args.document, args.operationName);
@@ -21,3 +23,16 @@ function normalizedExecutor(args) {
21
23
  })
22
24
  .resolve();
23
25
  }
26
+ exports.executorFromSchema = (0, utils_1.memoize1)(function executorFromSchema(schema) {
27
+ return function schemaExecutor(request) {
28
+ return normalizedExecutor({
29
+ schema,
30
+ document: request.document,
31
+ variableValues: request.variables,
32
+ operationName: request.operationName,
33
+ rootValue: request.rootValue,
34
+ contextValue: request.context,
35
+ signal: request.signal || request.info?.signal,
36
+ });
37
+ };
38
+ });
@@ -378,6 +378,7 @@ export function buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, p
378
378
  rootValue: exeContext.rootValue,
379
379
  operation: exeContext.operation,
380
380
  variableValues: exeContext.variableValues,
381
+ signal: exeContext.signal,
381
382
  };
382
383
  }
383
384
  export const CRITICAL_ERROR = 'CRITICAL_ERROR';
@@ -489,7 +490,7 @@ function getStreamValues(exeContext, fieldNodes, path) {
489
490
  async function completeAsyncIteratorValue(exeContext, itemType, fieldNodes, info, path, iterator, asyncPayloadRecord) {
490
491
  exeContext.signal?.addEventListener('abort', () => {
491
492
  iterator.return?.();
492
- });
493
+ }, { once: true });
493
494
  const errors = asyncPayloadRecord?.errors ?? exeContext.errors;
494
495
  const stream = getStreamValues(exeContext, fieldNodes, path);
495
496
  let containsPromise = false;
@@ -1177,7 +1178,7 @@ function yieldSubsequentPayloads(exeContext) {
1177
1178
  exeContext.signal?.addEventListener('abort', () => {
1178
1179
  isDone = true;
1179
1180
  reject(exeContext.signal?.reason);
1180
- });
1181
+ }, { once: true });
1181
1182
  });
1182
1183
  async function next() {
1183
1184
  if (isDone) {
@@ -1226,7 +1227,7 @@ function yieldSubsequentPayloads(exeContext) {
1226
1227
  async throw(error) {
1227
1228
  await returnStreamIterators();
1228
1229
  isDone = true;
1229
- return Promise.reject(error);
1230
+ throw error;
1230
1231
  },
1231
1232
  async [DisposableSymbols.asyncDispose]() {
1232
1233
  await returnStreamIterators();
@@ -1,5 +1,6 @@
1
1
  import { getOperationAST } from 'graphql';
2
2
  import { ValueOrPromise } from 'value-or-promise';
3
+ import { memoize1, } from '@graphql-tools/utils';
3
4
  import { execute, flattenIncrementalResults, subscribe } from './execute.js';
4
5
  export function normalizedExecutor(args) {
5
6
  const operationAST = getOperationAST(args.document, args.operationName);
@@ -18,3 +19,16 @@ export function normalizedExecutor(args) {
18
19
  })
19
20
  .resolve();
20
21
  }
22
+ export const executorFromSchema = memoize1(function executorFromSchema(schema) {
23
+ return function schemaExecutor(request) {
24
+ return normalizedExecutor({
25
+ schema,
26
+ document: request.document,
27
+ variableValues: request.variables,
28
+ operationName: request.operationName,
29
+ rootValue: request.rootValue,
30
+ contextValue: request.context,
31
+ signal: request.signal || request.info?.signal,
32
+ });
33
+ };
34
+ });
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@graphql-tools/executor",
3
- "version": "1.3.7",
3
+ "version": "1.3.8",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
7
7
  },
8
8
  "dependencies": {
9
- "@graphql-tools/utils": "^10.6.2",
9
+ "@graphql-tools/utils": "^10.6.3",
10
10
  "@graphql-typed-document-node/core": "^3.2.0",
11
11
  "@repeaterjs/repeater": "^3.0.4",
12
12
  "@whatwg-node/disposablestack": "^0.0.5",
@@ -1,5 +1,5 @@
1
- import { DocumentNode, FieldNode, FragmentDefinitionNode, GraphQLError, GraphQLField, GraphQLFieldResolver, GraphQLFormattedError, GraphQLObjectType, GraphQLResolveInfo, GraphQLSchema, GraphQLTypeResolver, OperationDefinitionNode } from 'graphql';
2
- import { Maybe, MaybePromise, Path } from '@graphql-tools/utils';
1
+ import { DocumentNode, FieldNode, FragmentDefinitionNode, GraphQLError, GraphQLField, GraphQLFieldResolver, GraphQLFormattedError, GraphQLObjectType, GraphQLSchema, GraphQLTypeResolver, OperationDefinitionNode } from 'graphql';
2
+ import { GraphQLResolveInfo, Maybe, MaybePromise, Path } from '@graphql-tools/utils';
3
3
  import { TypedDocumentNode } from '@graphql-typed-document-node/core';
4
4
  export interface SingularExecutionResult<TData = any, TExtensions = any> {
5
5
  errors?: ReadonlyArray<GraphQLError>;
@@ -1,5 +1,5 @@
1
- import { DocumentNode, FieldNode, FragmentDefinitionNode, GraphQLError, GraphQLField, GraphQLFieldResolver, GraphQLFormattedError, GraphQLObjectType, GraphQLResolveInfo, GraphQLSchema, GraphQLTypeResolver, OperationDefinitionNode } from 'graphql';
2
- import { Maybe, MaybePromise, Path } from '@graphql-tools/utils';
1
+ import { DocumentNode, FieldNode, FragmentDefinitionNode, GraphQLError, GraphQLField, GraphQLFieldResolver, GraphQLFormattedError, GraphQLObjectType, GraphQLSchema, GraphQLTypeResolver, OperationDefinitionNode } from 'graphql';
2
+ import { GraphQLResolveInfo, Maybe, MaybePromise, Path } from '@graphql-tools/utils';
3
3
  import { TypedDocumentNode } from '@graphql-typed-document-node/core';
4
4
  export interface SingularExecutionResult<TData = any, TExtensions = any> {
5
5
  errors?: ReadonlyArray<GraphQLError>;
@@ -1,3 +1,5 @@
1
- import { ExecutionResult, MaybeAsyncIterable, MaybePromise } from '@graphql-tools/utils';
1
+ import { GraphQLSchema } from 'graphql';
2
+ import { ExecutionResult, Executor, MaybeAsyncIterable, MaybePromise } from '@graphql-tools/utils';
2
3
  import { ExecutionArgs } from './execute.cjs';
3
4
  export declare function normalizedExecutor<TData = any, TVariables = any, TContext = any>(args: ExecutionArgs<TData, TVariables, TContext>): MaybePromise<MaybeAsyncIterable<ExecutionResult<TData>>>;
5
+ export declare const executorFromSchema: (schema: GraphQLSchema) => Executor;
@@ -1,3 +1,5 @@
1
- import { ExecutionResult, MaybeAsyncIterable, MaybePromise } from '@graphql-tools/utils';
1
+ import { GraphQLSchema } from 'graphql';
2
+ import { ExecutionResult, Executor, MaybeAsyncIterable, MaybePromise } from '@graphql-tools/utils';
2
3
  import { ExecutionArgs } from './execute.js';
3
4
  export declare function normalizedExecutor<TData = any, TVariables = any, TContext = any>(args: ExecutionArgs<TData, TVariables, TContext>): MaybePromise<MaybeAsyncIterable<ExecutionResult<TData>>>;
5
+ export declare const executorFromSchema: (schema: GraphQLSchema) => Executor;