@graphql-tools/utils 8.6.0-alpha-06eec860.0 → 8.6.0

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.
@@ -8,3 +8,4 @@ interface AggregateErrorConstructor {
8
8
  }
9
9
  declare let AggregateErrorImpl: AggregateErrorConstructor;
10
10
  export { AggregateErrorImpl as AggregateError };
11
+ export declare function isAggregateError(error: Error): error is AggregateError;
package/executor.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ExecutionResult, ExecutionRequest } from './Interfaces';
2
2
  declare type MaybePromise<T> = Promise<T> | T;
3
- declare type MaybeAsyncIterableIterator<T> = AsyncIterableIterator<T> | T;
4
- export declare type AsyncExecutor<TBaseContext = Record<string, any>, TBaseExtensions = Record<string, any>> = <TReturn = any, TArgs = Record<string, any>, TContext extends TBaseContext = TBaseContext, TRoot = any, TExtensions extends TBaseExtensions = TBaseExtensions>(request: ExecutionRequest<TArgs, TContext, TRoot, TExtensions>) => Promise<MaybeAsyncIterableIterator<ExecutionResult<TReturn>>>;
3
+ declare type MaybeAsyncIterable<T> = AsyncIterable<T> | T;
4
+ export declare type AsyncExecutor<TBaseContext = Record<string, any>, TBaseExtensions = Record<string, any>> = <TReturn = any, TArgs = Record<string, any>, TContext extends TBaseContext = TBaseContext, TRoot = any, TExtensions extends TBaseExtensions = TBaseExtensions>(request: ExecutionRequest<TArgs, TContext, TRoot, TExtensions>) => Promise<MaybeAsyncIterable<ExecutionResult<TReturn>>>;
5
5
  export declare type SyncExecutor<TBaseContext = Record<string, any>, TBaseExtensions = Record<string, any>> = <TReturn = any, TArgs = Record<string, any>, TContext extends TBaseContext = TBaseContext, TRoot = any, TExtensions extends TBaseExtensions = TBaseExtensions>(request: ExecutionRequest<TArgs, TContext, TRoot, TExtensions>) => ExecutionResult<TReturn>;
6
- export declare type Executor<TBaseContext = Record<string, any>, TBaseExtensions = Record<string, any>> = <TReturn = any, TArgs = Record<string, any>, TContext extends TBaseContext = TBaseContext, TRoot = any, TExtensions extends TBaseExtensions = TBaseExtensions>(request: ExecutionRequest<TArgs, TContext, TRoot, TExtensions>) => MaybePromise<MaybeAsyncIterableIterator<ExecutionResult<TReturn>>>;
6
+ export declare type Executor<TBaseContext = Record<string, any>, TBaseExtensions = Record<string, any>> = <TReturn = any, TArgs = Record<string, any>, TContext extends TBaseContext = TBaseContext, TRoot = any, TExtensions extends TBaseExtensions = TBaseExtensions>(request: ExecutionRequest<TArgs, TContext, TRoot, TExtensions>) => MaybePromise<MaybeAsyncIterable<ExecutionResult<TReturn>>>;
7
7
  export {};
package/index.d.ts CHANGED
@@ -48,4 +48,3 @@ export * from './inspect';
48
48
  export * from './memoize';
49
49
  export * from './fixSchemaAst';
50
50
  export * from './getOperationASTFromRequest';
51
- export * from './path';
package/index.js CHANGED
@@ -69,9 +69,27 @@ function assertSome(input, message = 'Value should be something') {
69
69
  }
70
70
  }
71
71
 
72
+ if (typeof AggregateError === 'undefined') {
73
+ class AggregateErrorClass extends Error {
74
+ constructor(errors, message = '') {
75
+ super(message);
76
+ this.errors = errors;
77
+ this.name = 'AggregateError';
78
+ Error.captureStackTrace(this, AggregateErrorClass);
79
+ }
80
+ }
81
+ exports.AggregateError = function (errors, message) {
82
+ return new AggregateErrorClass(errors, message);
83
+ };
84
+ }
85
+ else {
86
+ exports.AggregateError = AggregateError;
87
+ }
88
+ function isAggregateError(error) {
89
+ return 'errors' in error && Array.isArray(error['errors']);
90
+ }
91
+
72
92
  // Taken from graphql-js
73
- // https://github.com/graphql/graphql-js/blob/main/src/jsutils/inspect.ts
74
- /* eslint-disable @typescript-eslint/ban-types */
75
93
  const MAX_ARRAY_LENGTH = 10;
76
94
  const MAX_RECURSIVE_DEPTH = 2;
77
95
  /**
@@ -92,10 +110,22 @@ function formatValue(value, seenValues) {
92
110
  return String(value);
93
111
  }
94
112
  }
113
+ function formatError(value) {
114
+ if (value instanceof graphql.GraphQLError) {
115
+ return value.toString();
116
+ }
117
+ return `${value.name}: ${value.message};\n ${value.stack}`;
118
+ }
95
119
  function formatObjectValue(value, previouslySeenValues) {
96
120
  if (value === null) {
97
121
  return 'null';
98
122
  }
123
+ if (value instanceof Error) {
124
+ if (isAggregateError(value)) {
125
+ return formatError(value) + '\n' + formatArray(value.errors, previouslySeenValues);
126
+ }
127
+ return formatError(value);
128
+ }
99
129
  if (previouslySeenValues.includes(value)) {
100
130
  return '[Circular]';
101
131
  }
@@ -176,7 +206,6 @@ function getArgumentValues(def, node, variableValues = {}) {
176
206
  [key]: value,
177
207
  }), {});
178
208
  const coercedValues = {};
179
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
180
209
  const argumentNodes = (_a = node.arguments) !== null && _a !== void 0 ? _a : [];
181
210
  const argNodeMap = argumentNodes.reduce((prev, arg) => ({
182
211
  ...prev,
@@ -1013,10 +1042,10 @@ function astFromScalarType(type, schema, pathToDirectivesInExtensions) {
1013
1042
  const directives = directivesInExtensions
1014
1043
  ? makeDirectiveNodes(schema, directivesInExtensions)
1015
1044
  : ((_a = type.astNode) === null || _a === void 0 ? void 0 : _a.directives) || [];
1016
- if (type['specifiedByUrl'] &&
1017
- !directives.some(directiveNode => directiveNode.name.value === 'specifiedBy')) {
1045
+ const specifiedByValue = (type['specifiedByUrl'] || type['specifiedByURL']);
1046
+ if (specifiedByValue && !directives.some(directiveNode => directiveNode.name.value === 'specifiedBy')) {
1018
1047
  const specifiedByArgs = {
1019
- url: type['specifiedByUrl'],
1048
+ url: specifiedByValue,
1020
1049
  };
1021
1050
  directives.push(makeDirectiveNode('specifiedBy', specifiedByArgs));
1022
1051
  }
@@ -1164,21 +1193,6 @@ function makeDirectiveNodes(schema, directiveValues) {
1164
1193
  return directiveNodes;
1165
1194
  }
1166
1195
 
1167
- exports.AggregateError = globalThis.AggregateError;
1168
- if (typeof exports.AggregateError === 'undefined') {
1169
- class AggregateErrorClass extends Error {
1170
- constructor(errors, message = '') {
1171
- super(message);
1172
- this.errors = errors;
1173
- this.name = 'AggregateError';
1174
- Error.captureStackTrace(this, AggregateErrorClass);
1175
- }
1176
- }
1177
- exports.AggregateError = function (errors, message) {
1178
- return new AggregateErrorClass(errors, message);
1179
- };
1180
- }
1181
-
1182
1196
  async function validateGraphQlDocuments(schema, documentFiles, effectiveRules = createDefaultRules()) {
1183
1197
  const allFragmentMap = new Map();
1184
1198
  const documentFileObjectsToValidate = [];
@@ -3323,7 +3337,6 @@ function visitTypes(pruningContext, schema) {
3323
3337
  }
3324
3338
  }
3325
3339
 
3326
- // eslint-disable-next-line @typescript-eslint/ban-types
3327
3340
  function mergeDeep(sources, respectPrototype = false) {
3328
3341
  const target = sources[0] || {};
3329
3342
  const output = {};
@@ -4152,24 +4165,64 @@ function valueMatchesCriteria(value, criteria) {
4152
4165
  }
4153
4166
 
4154
4167
  function isAsyncIterable(value) {
4155
- return typeof value === 'object' && value != null && Symbol.asyncIterator in value;
4168
+ return (typeof value === 'object' &&
4169
+ value != null &&
4170
+ Symbol.asyncIterator in value &&
4171
+ typeof value[Symbol.asyncIterator] === 'function');
4156
4172
  }
4157
4173
 
4158
4174
  function isDocumentNode(object) {
4159
4175
  return object && typeof object === 'object' && 'kind' in object && object.kind === graphql.Kind.DOCUMENT;
4160
4176
  }
4161
4177
 
4162
- function withCancel(asyncIteratorLike, onCancel) {
4163
- const asyncIterator = asyncIteratorLike[Symbol.asyncIterator]();
4164
- if (!asyncIterator.return) {
4165
- asyncIterator.return = () => Promise.resolve({ value: undefined, done: true });
4166
- }
4167
- const savedReturn = asyncIterator.return.bind(asyncIterator);
4168
- asyncIterator.return = () => {
4169
- onCancel();
4170
- return savedReturn();
4178
+ async function defaultAsyncIteratorReturn(value) {
4179
+ return { value, done: true };
4180
+ }
4181
+ const proxyMethodFactory = memoize2(function proxyMethodFactory(target, targetMethod) {
4182
+ return function proxyMethod(...args) {
4183
+ return Reflect.apply(targetMethod, target, args);
4171
4184
  };
4172
- return asyncIterator;
4185
+ });
4186
+ function getAsyncIteratorWithCancel(asyncIterator, onCancel) {
4187
+ return new Proxy(asyncIterator, {
4188
+ has(asyncIterator, prop) {
4189
+ if (prop === 'return') {
4190
+ return true;
4191
+ }
4192
+ return Reflect.has(asyncIterator, prop);
4193
+ },
4194
+ get(asyncIterator, prop, receiver) {
4195
+ const existingPropValue = Reflect.get(asyncIterator, prop, receiver);
4196
+ if (prop === 'return') {
4197
+ const existingReturn = existingPropValue || defaultAsyncIteratorReturn;
4198
+ return async function returnWithCancel(value) {
4199
+ const returnValue = await onCancel(value);
4200
+ return Reflect.apply(existingReturn, asyncIterator, [returnValue]);
4201
+ };
4202
+ }
4203
+ else if (typeof existingPropValue === 'function') {
4204
+ return proxyMethodFactory(asyncIterator, existingPropValue);
4205
+ }
4206
+ return existingPropValue;
4207
+ },
4208
+ });
4209
+ }
4210
+ function getAsyncIterableWithCancel(asyncIterable, onCancel) {
4211
+ return new Proxy(asyncIterable, {
4212
+ get(asyncIterable, prop, receiver) {
4213
+ const existingPropValue = Reflect.get(asyncIterable, prop, receiver);
4214
+ if (Symbol.asyncIterator === prop) {
4215
+ return function asyncIteratorFactory() {
4216
+ const asyncIterator = Reflect.apply(existingPropValue, asyncIterable, []);
4217
+ return getAsyncIteratorWithCancel(asyncIterator, onCancel);
4218
+ };
4219
+ }
4220
+ else if (typeof existingPropValue === 'function') {
4221
+ return proxyMethodFactory(asyncIterable, existingPropValue);
4222
+ }
4223
+ return existingPropValue;
4224
+ },
4225
+ });
4173
4226
  }
4174
4227
 
4175
4228
  function buildFixedSchema(schema, options) {
@@ -4193,17 +4246,6 @@ function fixSchemaAst(schema, options) {
4193
4246
  return schema;
4194
4247
  }
4195
4248
 
4196
- function joinPaths(...paths) {
4197
- const seperator = paths.some(path => path.includes('\\')) ? '\\' : '/';
4198
- return paths.join(seperator);
4199
- }
4200
- function isAbsolutePath(path) {
4201
- if (path.includes('\\')) {
4202
- return path[1] === ':';
4203
- }
4204
- return path.startsWith('/');
4205
- }
4206
-
4207
4249
  exports.addTypes = addTypes;
4208
4250
  exports.appendObjectFields = appendObjectFields;
4209
4251
  exports.asArray = asArray;
@@ -4239,6 +4281,8 @@ exports.fixSchemaAst = fixSchemaAst;
4239
4281
  exports.forEachDefaultValue = forEachDefaultValue;
4240
4282
  exports.forEachField = forEachField;
4241
4283
  exports.getArgumentValues = getArgumentValues;
4284
+ exports.getAsyncIterableWithCancel = getAsyncIterableWithCancel;
4285
+ exports.getAsyncIteratorWithCancel = getAsyncIteratorWithCancel;
4242
4286
  exports.getBlockStringIndentation = getBlockStringIndentation;
4243
4287
  exports.getBuiltInForStub = getBuiltInForStub;
4244
4288
  exports.getComment = getComment;
@@ -4265,7 +4309,7 @@ exports.healSchema = healSchema;
4265
4309
  exports.healTypes = healTypes;
4266
4310
  exports.implementsAbstractType = implementsAbstractType;
4267
4311
  exports.inspect = inspect;
4268
- exports.isAbsolutePath = isAbsolutePath;
4312
+ exports.isAggregateError = isAggregateError;
4269
4313
  exports.isAsyncIterable = isAsyncIterable;
4270
4314
  exports.isDescribable = isDescribable;
4271
4315
  exports.isDocumentNode = isDocumentNode;
@@ -4273,7 +4317,6 @@ exports.isDocumentString = isDocumentString;
4273
4317
  exports.isNamedStub = isNamedStub;
4274
4318
  exports.isSome = isSome;
4275
4319
  exports.isValidPath = isValidPath;
4276
- exports.joinPaths = joinPaths;
4277
4320
  exports.makeDeprecatedDirective = makeDeprecatedDirective;
4278
4321
  exports.makeDirectiveNode = makeDirectiveNode;
4279
4322
  exports.makeDirectiveNodes = makeDirectiveNodes;
@@ -4314,4 +4357,4 @@ exports.valueMatchesCriteria = valueMatchesCriteria;
4314
4357
  exports.visitData = visitData;
4315
4358
  exports.visitErrors = visitErrors;
4316
4359
  exports.visitResult = visitResult;
4317
- exports.withCancel = withCancel;
4360
+ exports.withCancel = getAsyncIterableWithCancel;
package/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { parse, isNonNullType, GraphQLError, Kind, valueFromAST, print, isObjectType, isListType, isSpecifiedDirective, astFromValue, isSpecifiedScalarType, isIntrospectionType, isInterfaceType, isUnionType, isInputObjectType, isEnumType, isScalarType, GraphQLDeprecatedDirective, specifiedRules, concatAST, validate, versionInfo, buildClientSchema, visit, TokenKind, Source, isTypeSystemDefinitionNode, getNamedType, GraphQLString, GraphQLNonNull, GraphQLList, GraphQLID, GraphQLBoolean, GraphQLFloat, GraphQLInt, GraphQLObjectType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLDirective, GraphQLUnionType, GraphQLEnumType, GraphQLScalarType, isNamedType, getNullableType, isLeafType, GraphQLSchema, isDirective, isCompositeType, doTypesOverlap, getOperationAST, getDirectiveValues, GraphQLSkipDirective, GraphQLIncludeDirective, typeFromAST, isAbstractType, getOperationRootType, TypeNameMetaFieldDef, buildASTSchema } from 'graphql';
1
+ import { parse, GraphQLError, isNonNullType, Kind, valueFromAST, print, isObjectType, isListType, isSpecifiedDirective, astFromValue, isSpecifiedScalarType, isIntrospectionType, isInterfaceType, isUnionType, isInputObjectType, isEnumType, isScalarType, GraphQLDeprecatedDirective, specifiedRules, concatAST, validate, versionInfo, buildClientSchema, visit, TokenKind, Source, isTypeSystemDefinitionNode, getNamedType, GraphQLString, GraphQLNonNull, GraphQLList, GraphQLID, GraphQLBoolean, GraphQLFloat, GraphQLInt, GraphQLObjectType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLDirective, GraphQLUnionType, GraphQLEnumType, GraphQLScalarType, isNamedType, getNullableType, isLeafType, GraphQLSchema, isDirective, isCompositeType, doTypesOverlap, getOperationAST, getDirectiveValues, GraphQLSkipDirective, GraphQLIncludeDirective, typeFromAST, isAbstractType, getOperationRootType, TypeNameMetaFieldDef, buildASTSchema } from 'graphql';
2
2
 
3
3
  const asArray = (fns) => (Array.isArray(fns) ? fns : fns ? [fns] : []);
4
4
  const invalidDocRegex = /\.[a-z0-9]+$/i;
@@ -65,9 +65,28 @@ function assertSome(input, message = 'Value should be something') {
65
65
  }
66
66
  }
67
67
 
68
+ let AggregateErrorImpl;
69
+ if (typeof AggregateError === 'undefined') {
70
+ class AggregateErrorClass extends Error {
71
+ constructor(errors, message = '') {
72
+ super(message);
73
+ this.errors = errors;
74
+ this.name = 'AggregateError';
75
+ Error.captureStackTrace(this, AggregateErrorClass);
76
+ }
77
+ }
78
+ AggregateErrorImpl = function (errors, message) {
79
+ return new AggregateErrorClass(errors, message);
80
+ };
81
+ }
82
+ else {
83
+ AggregateErrorImpl = AggregateError;
84
+ }
85
+ function isAggregateError(error) {
86
+ return 'errors' in error && Array.isArray(error['errors']);
87
+ }
88
+
68
89
  // Taken from graphql-js
69
- // https://github.com/graphql/graphql-js/blob/main/src/jsutils/inspect.ts
70
- /* eslint-disable @typescript-eslint/ban-types */
71
90
  const MAX_ARRAY_LENGTH = 10;
72
91
  const MAX_RECURSIVE_DEPTH = 2;
73
92
  /**
@@ -88,10 +107,22 @@ function formatValue(value, seenValues) {
88
107
  return String(value);
89
108
  }
90
109
  }
110
+ function formatError(value) {
111
+ if (value instanceof GraphQLError) {
112
+ return value.toString();
113
+ }
114
+ return `${value.name}: ${value.message};\n ${value.stack}`;
115
+ }
91
116
  function formatObjectValue(value, previouslySeenValues) {
92
117
  if (value === null) {
93
118
  return 'null';
94
119
  }
120
+ if (value instanceof Error) {
121
+ if (isAggregateError(value)) {
122
+ return formatError(value) + '\n' + formatArray(value.errors, previouslySeenValues);
123
+ }
124
+ return formatError(value);
125
+ }
95
126
  if (previouslySeenValues.includes(value)) {
96
127
  return '[Circular]';
97
128
  }
@@ -172,7 +203,6 @@ function getArgumentValues(def, node, variableValues = {}) {
172
203
  [key]: value,
173
204
  }), {});
174
205
  const coercedValues = {};
175
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
176
206
  const argumentNodes = (_a = node.arguments) !== null && _a !== void 0 ? _a : [];
177
207
  const argNodeMap = argumentNodes.reduce((prev, arg) => ({
178
208
  ...prev,
@@ -1009,10 +1039,10 @@ function astFromScalarType(type, schema, pathToDirectivesInExtensions) {
1009
1039
  const directives = directivesInExtensions
1010
1040
  ? makeDirectiveNodes(schema, directivesInExtensions)
1011
1041
  : ((_a = type.astNode) === null || _a === void 0 ? void 0 : _a.directives) || [];
1012
- if (type['specifiedByUrl'] &&
1013
- !directives.some(directiveNode => directiveNode.name.value === 'specifiedBy')) {
1042
+ const specifiedByValue = (type['specifiedByUrl'] || type['specifiedByURL']);
1043
+ if (specifiedByValue && !directives.some(directiveNode => directiveNode.name.value === 'specifiedBy')) {
1014
1044
  const specifiedByArgs = {
1015
- url: type['specifiedByUrl'],
1045
+ url: specifiedByValue,
1016
1046
  };
1017
1047
  directives.push(makeDirectiveNode('specifiedBy', specifiedByArgs));
1018
1048
  }
@@ -1160,21 +1190,6 @@ function makeDirectiveNodes(schema, directiveValues) {
1160
1190
  return directiveNodes;
1161
1191
  }
1162
1192
 
1163
- let AggregateErrorImpl = globalThis.AggregateError;
1164
- if (typeof AggregateErrorImpl === 'undefined') {
1165
- class AggregateErrorClass extends Error {
1166
- constructor(errors, message = '') {
1167
- super(message);
1168
- this.errors = errors;
1169
- this.name = 'AggregateError';
1170
- Error.captureStackTrace(this, AggregateErrorClass);
1171
- }
1172
- }
1173
- AggregateErrorImpl = function (errors, message) {
1174
- return new AggregateErrorClass(errors, message);
1175
- };
1176
- }
1177
-
1178
1193
  async function validateGraphQlDocuments(schema, documentFiles, effectiveRules = createDefaultRules()) {
1179
1194
  const allFragmentMap = new Map();
1180
1195
  const documentFileObjectsToValidate = [];
@@ -3320,7 +3335,6 @@ function visitTypes(pruningContext, schema) {
3320
3335
  }
3321
3336
  }
3322
3337
 
3323
- // eslint-disable-next-line @typescript-eslint/ban-types
3324
3338
  function mergeDeep(sources, respectPrototype = false) {
3325
3339
  const target = sources[0] || {};
3326
3340
  const output = {};
@@ -4149,24 +4163,64 @@ function valueMatchesCriteria(value, criteria) {
4149
4163
  }
4150
4164
 
4151
4165
  function isAsyncIterable(value) {
4152
- return typeof value === 'object' && value != null && Symbol.asyncIterator in value;
4166
+ return (typeof value === 'object' &&
4167
+ value != null &&
4168
+ Symbol.asyncIterator in value &&
4169
+ typeof value[Symbol.asyncIterator] === 'function');
4153
4170
  }
4154
4171
 
4155
4172
  function isDocumentNode(object) {
4156
4173
  return object && typeof object === 'object' && 'kind' in object && object.kind === Kind.DOCUMENT;
4157
4174
  }
4158
4175
 
4159
- function withCancel(asyncIteratorLike, onCancel) {
4160
- const asyncIterator = asyncIteratorLike[Symbol.asyncIterator]();
4161
- if (!asyncIterator.return) {
4162
- asyncIterator.return = () => Promise.resolve({ value: undefined, done: true });
4163
- }
4164
- const savedReturn = asyncIterator.return.bind(asyncIterator);
4165
- asyncIterator.return = () => {
4166
- onCancel();
4167
- return savedReturn();
4176
+ async function defaultAsyncIteratorReturn(value) {
4177
+ return { value, done: true };
4178
+ }
4179
+ const proxyMethodFactory = memoize2(function proxyMethodFactory(target, targetMethod) {
4180
+ return function proxyMethod(...args) {
4181
+ return Reflect.apply(targetMethod, target, args);
4168
4182
  };
4169
- return asyncIterator;
4183
+ });
4184
+ function getAsyncIteratorWithCancel(asyncIterator, onCancel) {
4185
+ return new Proxy(asyncIterator, {
4186
+ has(asyncIterator, prop) {
4187
+ if (prop === 'return') {
4188
+ return true;
4189
+ }
4190
+ return Reflect.has(asyncIterator, prop);
4191
+ },
4192
+ get(asyncIterator, prop, receiver) {
4193
+ const existingPropValue = Reflect.get(asyncIterator, prop, receiver);
4194
+ if (prop === 'return') {
4195
+ const existingReturn = existingPropValue || defaultAsyncIteratorReturn;
4196
+ return async function returnWithCancel(value) {
4197
+ const returnValue = await onCancel(value);
4198
+ return Reflect.apply(existingReturn, asyncIterator, [returnValue]);
4199
+ };
4200
+ }
4201
+ else if (typeof existingPropValue === 'function') {
4202
+ return proxyMethodFactory(asyncIterator, existingPropValue);
4203
+ }
4204
+ return existingPropValue;
4205
+ },
4206
+ });
4207
+ }
4208
+ function getAsyncIterableWithCancel(asyncIterable, onCancel) {
4209
+ return new Proxy(asyncIterable, {
4210
+ get(asyncIterable, prop, receiver) {
4211
+ const existingPropValue = Reflect.get(asyncIterable, prop, receiver);
4212
+ if (Symbol.asyncIterator === prop) {
4213
+ return function asyncIteratorFactory() {
4214
+ const asyncIterator = Reflect.apply(existingPropValue, asyncIterable, []);
4215
+ return getAsyncIteratorWithCancel(asyncIterator, onCancel);
4216
+ };
4217
+ }
4218
+ else if (typeof existingPropValue === 'function') {
4219
+ return proxyMethodFactory(asyncIterable, existingPropValue);
4220
+ }
4221
+ return existingPropValue;
4222
+ },
4223
+ });
4170
4224
  }
4171
4225
 
4172
4226
  function buildFixedSchema(schema, options) {
@@ -4190,15 +4244,4 @@ function fixSchemaAst(schema, options) {
4190
4244
  return schema;
4191
4245
  }
4192
4246
 
4193
- function joinPaths(...paths) {
4194
- const seperator = paths.some(path => path.includes('\\')) ? '\\' : '/';
4195
- return paths.join(seperator);
4196
- }
4197
- function isAbsolutePath(path) {
4198
- if (path.includes('\\')) {
4199
- return path[1] === ':';
4200
- }
4201
- return path.startsWith('/');
4202
- }
4203
-
4204
- export { AggregateErrorImpl as AggregateError, MapperKind, addTypes, appendObjectFields, asArray, assertSome, astFromArg, astFromDirective, astFromEnumType, astFromEnumValue, astFromField, astFromInputField, astFromInputObjectType, astFromInterfaceType, astFromObjectType, astFromScalarType, astFromSchema, astFromUnionType, astFromValueUntyped, buildOperationNodeForField, checkValidationErrors, collectComment, collectFields, collectSubFields, compareNodes, compareStrings, correctASTNodes, createDefaultRules, createNamedStub, createStub, createVariableNameGenerator, dedentBlockStringValue, filterSchema, fixSchemaAst, forEachDefaultValue, forEachField, getArgumentValues, getBlockStringIndentation, getBuiltInForStub, getComment, getDefinedRootType, getDeprecatableDirectiveNodes, getDescription, getDirective, getDirectiveInExtensions, getDirectiveNodes, getDirectives, getDirectivesInExtensions, getDocumentNodeFromSchema, getFieldsWithDirectives, getImplementingTypes, getLeadingCommentBlock, getOperationASTFromDocument, getOperationASTFromRequest, getResolversFromSchema, getResponseKeyFromInfo, getRootTypeMap, getRootTypeNames, getRootTypes, healSchema, healTypes, implementsAbstractType, inspect, isAbsolutePath, isAsyncIterable, isDescribable, isDocumentNode, isDocumentString, isNamedStub, isSome, isValidPath, joinPaths, makeDeprecatedDirective, makeDirectiveNode, makeDirectiveNodes, mapAsyncIterator, mapSchema, memoize1, memoize2, memoize2of4, memoize3, memoize4, memoize5, mergeDeep, modifyObjectFields, nodeToString, observableToAsyncIterable, parseGraphQLJSON, parseGraphQLSDL, parseInputValue, parseInputValueLiteral, parseSelectionSet, printComment, printSchemaWithDirectives, printWithComments, pruneSchema, pushComment, relocatedError, removeObjectFields, renameType, resetComments, rewireTypes, selectObjectFields, serializeInputValue, transformCommentsToDescriptions, transformInputValue, updateArgument, validateGraphQlDocuments, valueMatchesCriteria, visitData, visitErrors, visitResult, withCancel };
4247
+ export { AggregateErrorImpl as AggregateError, MapperKind, addTypes, appendObjectFields, asArray, assertSome, astFromArg, astFromDirective, astFromEnumType, astFromEnumValue, astFromField, astFromInputField, astFromInputObjectType, astFromInterfaceType, astFromObjectType, astFromScalarType, astFromSchema, astFromUnionType, astFromValueUntyped, buildOperationNodeForField, checkValidationErrors, collectComment, collectFields, collectSubFields, compareNodes, compareStrings, correctASTNodes, createDefaultRules, createNamedStub, createStub, createVariableNameGenerator, dedentBlockStringValue, filterSchema, fixSchemaAst, forEachDefaultValue, forEachField, getArgumentValues, getAsyncIterableWithCancel, getAsyncIteratorWithCancel, getBlockStringIndentation, getBuiltInForStub, getComment, getDefinedRootType, getDeprecatableDirectiveNodes, getDescription, getDirective, getDirectiveInExtensions, getDirectiveNodes, getDirectives, getDirectivesInExtensions, getDocumentNodeFromSchema, getFieldsWithDirectives, getImplementingTypes, getLeadingCommentBlock, getOperationASTFromDocument, getOperationASTFromRequest, getResolversFromSchema, getResponseKeyFromInfo, getRootTypeMap, getRootTypeNames, getRootTypes, healSchema, healTypes, implementsAbstractType, inspect, isAggregateError, isAsyncIterable, isDescribable, isDocumentNode, isDocumentString, isNamedStub, isSome, isValidPath, makeDeprecatedDirective, makeDirectiveNode, makeDirectiveNodes, mapAsyncIterator, mapSchema, memoize1, memoize2, memoize2of4, memoize3, memoize4, memoize5, mergeDeep, modifyObjectFields, nodeToString, observableToAsyncIterable, parseGraphQLJSON, parseGraphQLSDL, parseInputValue, parseInputValueLiteral, parseSelectionSet, printComment, printSchemaWithDirectives, printWithComments, pruneSchema, pushComment, relocatedError, removeObjectFields, renameType, resetComments, rewireTypes, selectObjectFields, serializeInputValue, transformCommentsToDescriptions, transformInputValue, updateArgument, validateGraphQlDocuments, valueMatchesCriteria, visitData, visitErrors, visitResult, getAsyncIterableWithCancel as withCancel };
@@ -1 +1 @@
1
- export declare function isAsyncIterable<T>(value: any): value is AsyncIterableIterator<T>;
1
+ export declare function isAsyncIterable<T>(value: any): value is AsyncIterable<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/utils",
3
- "version": "8.6.0-alpha-06eec860.0",
3
+ "version": "8.6.0",
4
4
  "description": "Common package containing utils and types for GraphQL tools",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
@@ -30,6 +30,7 @@
30
30
  "./*": {
31
31
  "require": "./*.js",
32
32
  "import": "./*.mjs"
33
- }
33
+ },
34
+ "./package.json": "./package.json"
34
35
  }
35
36
  }
package/withCancel.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export declare function withCancel<T>(asyncIteratorLike: {
2
- [Symbol.asyncIterator](): AsyncIterator<T>;
3
- }, onCancel: () => void): AsyncIterator<T | undefined>;
1
+ export declare function getAsyncIteratorWithCancel<T, TReturn = any>(asyncIterator: AsyncIterator<T>, onCancel: (value?: TReturn) => void | Promise<void>): AsyncIterator<T>;
2
+ export declare function getAsyncIterableWithCancel<T, TAsyncIterable extends AsyncIterable<T>, TReturn = any>(asyncIterable: TAsyncIterable, onCancel: (value?: TReturn) => void | Promise<void>): TAsyncIterable;
3
+ export { getAsyncIterableWithCancel as withCancel };
package/path.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare function joinPaths(...paths: string[]): string;
2
- export declare function isAbsolutePath(path: string): boolean;