@graphql-tools/executor 1.0.0-rc-20230519104353-b09f3180 → 1.0.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.
@@ -34,12 +34,11 @@ function execute(args) {
34
34
  if (!('schema' in exeContext)) {
35
35
  return {
36
36
  errors: exeContext.map(e => {
37
- var _a;
38
37
  Object.defineProperty(e, 'extensions', {
39
38
  value: {
40
39
  ...e.extensions,
41
40
  http: {
42
- ...(_a = e.extensions) === null || _a === void 0 ? void 0 : _a['http'],
41
+ ...e.extensions?.['http'],
43
42
  status: 400,
44
43
  },
45
44
  },
@@ -136,7 +135,6 @@ exports.getFragmentsFromDocument = (0, utils_1.memoize1)(function getFragmentsFr
136
135
  * @internal
137
136
  */
138
137
  function buildExecutionContext(args) {
139
- var _a, _b;
140
138
  const { schema, document, rootValue, contextValue, variableValues: rawVariableValues, operationName, fieldResolver, typeResolver, subscribeFieldResolver, } = args;
141
139
  // If the schema used for execution is invalid, throw an error.
142
140
  (0, graphql_1.assertValidSchema)(schema);
@@ -151,7 +149,7 @@ function buildExecutionContext(args) {
151
149
  }
152
150
  operation = definition;
153
151
  }
154
- else if (((_a = definition.name) === null || _a === void 0 ? void 0 : _a.value) === operationName) {
152
+ else if (definition.name?.value === operationName) {
155
153
  operation = definition;
156
154
  }
157
155
  break;
@@ -167,8 +165,8 @@ function buildExecutionContext(args) {
167
165
  }
168
166
  // FIXME: https://github.com/graphql/graphql-js/issues/2203
169
167
  /* c8 ignore next */
170
- const variableDefinitions = (_b = operation.variableDefinitions) !== null && _b !== void 0 ? _b : [];
171
- const coercedVariableValues = (0, values_js_1.getVariableValues)(schema, variableDefinitions, rawVariableValues !== null && rawVariableValues !== void 0 ? rawVariableValues : {}, {
168
+ const variableDefinitions = operation.variableDefinitions ?? [];
169
+ const coercedVariableValues = (0, values_js_1.getVariableValues)(schema, variableDefinitions, rawVariableValues ?? {}, {
172
170
  maxErrors: 50,
173
171
  });
174
172
  if (coercedVariableValues.errors) {
@@ -181,9 +179,9 @@ function buildExecutionContext(args) {
181
179
  contextValue,
182
180
  operation,
183
181
  variableValues: coercedVariableValues.coerced,
184
- fieldResolver: fieldResolver !== null && fieldResolver !== void 0 ? fieldResolver : exports.defaultFieldResolver,
185
- typeResolver: typeResolver !== null && typeResolver !== void 0 ? typeResolver : exports.defaultTypeResolver,
186
- subscribeFieldResolver: subscribeFieldResolver !== null && subscribeFieldResolver !== void 0 ? subscribeFieldResolver : exports.defaultFieldResolver,
182
+ fieldResolver: fieldResolver ?? exports.defaultFieldResolver,
183
+ typeResolver: typeResolver ?? exports.defaultTypeResolver,
184
+ subscribeFieldResolver: subscribeFieldResolver ?? exports.defaultFieldResolver,
187
185
  subsequentPayloads: new Set(),
188
186
  errors: [],
189
187
  };
@@ -283,14 +281,13 @@ function executeFields(exeContext, parentType, sourceValue, path, fields, asyncP
283
281
  * serialize scalars, or execute the sub-selection-set for objects.
284
282
  */
285
283
  function executeField(exeContext, parentType, source, fieldNodes, path, asyncPayloadRecord) {
286
- var _a, _b;
287
- const errors = (_a = asyncPayloadRecord === null || asyncPayloadRecord === void 0 ? void 0 : asyncPayloadRecord.errors) !== null && _a !== void 0 ? _a : exeContext.errors;
284
+ const errors = asyncPayloadRecord?.errors ?? exeContext.errors;
288
285
  const fieldDef = getFieldDef(exeContext.schema, parentType, fieldNodes[0]);
289
286
  if (!fieldDef) {
290
287
  return;
291
288
  }
292
289
  const returnType = fieldDef.type;
293
- const resolveFn = (_b = fieldDef.resolve) !== null && _b !== void 0 ? _b : exeContext.fieldResolver;
290
+ const resolveFn = fieldDef.resolve ?? exeContext.fieldResolver;
294
291
  const info = buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path);
295
292
  // Get the resolve function, regardless of if its result is normal or abrupt (error).
296
293
  try {
@@ -453,8 +450,7 @@ function getStreamValues(exeContext, fieldNodes, path) {
453
450
  * recursively until all the results are completed.
454
451
  */
455
452
  async function completeAsyncIteratorValue(exeContext, itemType, fieldNodes, info, path, iterator, asyncPayloadRecord) {
456
- var _a;
457
- const errors = (_a = asyncPayloadRecord === null || asyncPayloadRecord === void 0 ? void 0 : asyncPayloadRecord.errors) !== null && _a !== void 0 ? _a : exeContext.errors;
453
+ const errors = asyncPayloadRecord?.errors ?? exeContext.errors;
458
454
  const stream = getStreamValues(exeContext, fieldNodes, path);
459
455
  let containsPromise = false;
460
456
  const completedResults = [];
@@ -489,9 +485,8 @@ async function completeAsyncIteratorValue(exeContext, itemType, fieldNodes, info
489
485
  * inner type
490
486
  */
491
487
  function completeListValue(exeContext, returnType, fieldNodes, info, path, result, asyncPayloadRecord) {
492
- var _a;
493
488
  const itemType = returnType.ofType;
494
- const errors = (_a = asyncPayloadRecord === null || asyncPayloadRecord === void 0 ? void 0 : asyncPayloadRecord.errors) !== null && _a !== void 0 ? _a : exeContext.errors;
489
+ const errors = asyncPayloadRecord?.errors ?? exeContext.errors;
495
490
  if ((0, utils_1.isAsyncIterable)(result)) {
496
491
  const iterator = result[Symbol.asyncIterator]();
497
492
  return completeAsyncIteratorValue(exeContext, itemType, fieldNodes, info, path, iterator, asyncPayloadRecord);
@@ -574,8 +569,7 @@ function completeLeafValue(returnType, result) {
574
569
  * of that value, then complete the value for that type.
575
570
  */
576
571
  function completeAbstractValue(exeContext, returnType, fieldNodes, info, path, result, asyncPayloadRecord) {
577
- var _a;
578
- const resolveTypeFn = (_a = returnType.resolveType) !== null && _a !== void 0 ? _a : exeContext.typeResolver;
572
+ const resolveTypeFn = returnType.resolveType ?? exeContext.typeResolver;
579
573
  const contextValue = exeContext.contextValue;
580
574
  const runtimeType = resolveTypeFn(result, contextValue, info, returnType);
581
575
  if ((0, utils_1.isPromise)(runtimeType)) {
@@ -745,12 +739,11 @@ function subscribe(args) {
745
739
  if (!('schema' in exeContext)) {
746
740
  return {
747
741
  errors: exeContext.map(e => {
748
- var _a;
749
742
  Object.defineProperty(e, 'extensions', {
750
743
  value: {
751
744
  ...e.extensions,
752
745
  http: {
753
- ...(_a = e.extensions) === null || _a === void 0 ? void 0 : _a['http'],
746
+ ...e.extensions?.['http'],
754
747
  status: 400,
755
748
  },
756
749
  },
@@ -842,7 +835,6 @@ function createSourceEventStreamImpl(exeContext) {
842
835
  }
843
836
  }
844
837
  function executeSubscription(exeContext) {
845
- var _a;
846
838
  const { schema, fragments, operation, variableValues, rootValue } = exeContext;
847
839
  const rootType = schema.getSubscriptionType();
848
840
  if (rootType == null) {
@@ -869,7 +861,7 @@ function executeSubscription(exeContext) {
869
861
  const contextValue = exeContext.contextValue;
870
862
  // Call the `subscribe()` resolver or the default resolver to produce an
871
863
  // AsyncIterable yielding raw payloads.
872
- const resolveFn = (_a = fieldDef.subscribe) !== null && _a !== void 0 ? _a : exeContext.subscribeFieldResolver;
864
+ const resolveFn = fieldDef.subscribe ?? exeContext.subscribeFieldResolver;
873
865
  const result = resolveFn(rootValue, args, contextValue, info);
874
866
  if ((0, utils_1.isPromise)(result)) {
875
867
  return result.then(assertEventStream).then(undefined, error => {
@@ -1006,7 +998,7 @@ async function executeStreamIteratorItem(iterator, exeContext, fieldNodes, info,
1006
998
  }
1007
999
  async function executeStreamIterator(initialIndex, iterator, exeContext, fieldNodes, info, itemType, path, label, parentContext) {
1008
1000
  let index = initialIndex;
1009
- let previousAsyncPayloadRecord = parentContext !== null && parentContext !== void 0 ? parentContext : undefined;
1001
+ let previousAsyncPayloadRecord = parentContext ?? undefined;
1010
1002
  while (true) {
1011
1003
  const itemPath = (0, utils_1.addPath)(path, index, undefined);
1012
1004
  const asyncPayloadRecord = new StreamRecord({
@@ -1025,7 +1017,7 @@ async function executeStreamIterator(initialIndex, iterator, exeContext, fieldNo
1025
1017
  filterSubsequentPayloads(exeContext, path, asyncPayloadRecord);
1026
1018
  asyncPayloadRecord.addItems(null);
1027
1019
  // entire stream has errored and bubbled upwards
1028
- if (iterator === null || iterator === void 0 ? void 0 : iterator.return) {
1020
+ if (iterator?.return) {
1029
1021
  iterator.return().catch(() => {
1030
1022
  // ignore errors
1031
1023
  });
@@ -1055,7 +1047,6 @@ async function executeStreamIterator(initialIndex, iterator, exeContext, fieldNo
1055
1047
  function filterSubsequentPayloads(exeContext, nullPath, currentAsyncRecord) {
1056
1048
  const nullPathArray = (0, utils_1.pathToArray)(nullPath);
1057
1049
  exeContext.subsequentPayloads.forEach(asyncRecord => {
1058
- var _a;
1059
1050
  if (asyncRecord === currentAsyncRecord) {
1060
1051
  // don't remove payload from where error originates
1061
1052
  return;
@@ -1067,7 +1058,7 @@ function filterSubsequentPayloads(exeContext, nullPath, currentAsyncRecord) {
1067
1058
  }
1068
1059
  }
1069
1060
  // asyncRecord path points to nulled error field
1070
- if (isStreamPayload(asyncRecord) && ((_a = asyncRecord.iterator) === null || _a === void 0 ? void 0 : _a.return)) {
1061
+ if (isStreamPayload(asyncRecord) && asyncRecord.iterator?.return) {
1071
1062
  asyncRecord.iterator.return().catch(() => {
1072
1063
  // ignore error
1073
1064
  });
@@ -1093,7 +1084,7 @@ function getCompletedIncrementalResults(exeContext) {
1093
1084
  }
1094
1085
  else {
1095
1086
  const data = asyncPayloadRecord.data;
1096
- incrementalResult.data = data !== null && data !== void 0 ? data : null;
1087
+ incrementalResult.data = data ?? null;
1097
1088
  }
1098
1089
  incrementalResult.path = asyncPayloadRecord.path;
1099
1090
  if (asyncPayloadRecord.label) {
@@ -1133,8 +1124,7 @@ function yieldSubsequentPayloads(exeContext) {
1133
1124
  function returnStreamIterators() {
1134
1125
  const promises = [];
1135
1126
  exeContext.subsequentPayloads.forEach(asyncPayloadRecord => {
1136
- var _a;
1137
- if (isStreamPayload(asyncPayloadRecord) && ((_a = asyncPayloadRecord.iterator) === null || _a === void 0 ? void 0 : _a.return)) {
1127
+ if (isStreamPayload(asyncPayloadRecord) && asyncPayloadRecord.iterator?.return) {
1138
1128
  promises.push(asyncPayloadRecord.iterator.return());
1139
1129
  }
1140
1130
  });
@@ -1178,13 +1168,12 @@ class DeferredFragmentRecord {
1178
1168
  });
1179
1169
  }
1180
1170
  addData(data) {
1181
- var _a, _b, _c;
1182
- const parentData = (_a = this.parentContext) === null || _a === void 0 ? void 0 : _a.promise;
1171
+ const parentData = this.parentContext?.promise;
1183
1172
  if (parentData) {
1184
- (_b = this._resolve) === null || _b === void 0 ? void 0 : _b.call(this, parentData.then(() => data));
1173
+ this._resolve?.(parentData.then(() => data));
1185
1174
  return;
1186
1175
  }
1187
- (_c = this._resolve) === null || _c === void 0 ? void 0 : _c.call(this, data);
1176
+ this._resolve?.(data);
1188
1177
  }
1189
1178
  }
1190
1179
  class StreamRecord {
@@ -1210,13 +1199,12 @@ class StreamRecord {
1210
1199
  });
1211
1200
  }
1212
1201
  addItems(items) {
1213
- var _a, _b, _c;
1214
- const parentData = (_a = this.parentContext) === null || _a === void 0 ? void 0 : _a.promise;
1202
+ const parentData = this.parentContext?.promise;
1215
1203
  if (parentData) {
1216
- (_b = this._resolve) === null || _b === void 0 ? void 0 : _b.call(this, parentData.then(() => items));
1204
+ this._resolve?.(parentData.then(() => items));
1217
1205
  return;
1218
1206
  }
1219
- (_c = this._resolve) === null || _c === void 0 ? void 0 : _c.call(this, items);
1207
+ this._resolve?.(items);
1220
1208
  }
1221
1209
  setIsCompletedIterator() {
1222
1210
  this.isCompletedIterator = true;
@@ -71,15 +71,13 @@ function flattenAsyncIterable(iterable) {
71
71
  return {
72
72
  next,
73
73
  async return() {
74
- var _a, _b;
75
74
  done = true;
76
- await Promise.all([(_a = currentNestedIterator === null || currentNestedIterator === void 0 ? void 0 : currentNestedIterator.return) === null || _a === void 0 ? void 0 : _a.call(currentNestedIterator), (_b = topIterator.return) === null || _b === void 0 ? void 0 : _b.call(topIterator)]);
75
+ await Promise.all([currentNestedIterator?.return?.(), topIterator.return?.()]);
77
76
  return { value: undefined, done: true };
78
77
  },
79
78
  async throw(error) {
80
- var _a, _b;
81
79
  done = true;
82
- await Promise.all([(_a = currentNestedIterator === null || currentNestedIterator === void 0 ? void 0 : currentNestedIterator.throw) === null || _a === void 0 ? void 0 : _a.call(currentNestedIterator, error), (_b = topIterator.throw) === null || _b === void 0 ? void 0 : _b.call(topIterator, error)]);
80
+ await Promise.all([currentNestedIterator?.throw?.(error), topIterator.throw?.(error)]);
83
81
  /* c8 ignore next */
84
82
  throw error;
85
83
  },
@@ -14,7 +14,7 @@ const utils_1 = require("@graphql-tools/utils");
14
14
  */
15
15
  function getVariableValues(schema, varDefNodes, inputs, options) {
16
16
  const errors = [];
17
- const maxErrors = options === null || options === void 0 ? void 0 : options.maxErrors;
17
+ const maxErrors = options?.maxErrors;
18
18
  try {
19
19
  const coerced = coerceVariableValues(schema, varDefNodes, inputs, error => {
20
20
  if (maxErrors != null && errors.length >= maxErrors) {
@@ -31,12 +31,11 @@ export function execute(args) {
31
31
  if (!('schema' in exeContext)) {
32
32
  return {
33
33
  errors: exeContext.map(e => {
34
- var _a;
35
34
  Object.defineProperty(e, 'extensions', {
36
35
  value: {
37
36
  ...e.extensions,
38
37
  http: {
39
- ...(_a = e.extensions) === null || _a === void 0 ? void 0 : _a['http'],
38
+ ...e.extensions?.['http'],
40
39
  status: 400,
41
40
  },
42
41
  },
@@ -130,7 +129,6 @@ export const getFragmentsFromDocument = memoize1(function getFragmentsFromDocume
130
129
  * @internal
131
130
  */
132
131
  export function buildExecutionContext(args) {
133
- var _a, _b;
134
132
  const { schema, document, rootValue, contextValue, variableValues: rawVariableValues, operationName, fieldResolver, typeResolver, subscribeFieldResolver, } = args;
135
133
  // If the schema used for execution is invalid, throw an error.
136
134
  assertValidSchema(schema);
@@ -145,7 +143,7 @@ export function buildExecutionContext(args) {
145
143
  }
146
144
  operation = definition;
147
145
  }
148
- else if (((_a = definition.name) === null || _a === void 0 ? void 0 : _a.value) === operationName) {
146
+ else if (definition.name?.value === operationName) {
149
147
  operation = definition;
150
148
  }
151
149
  break;
@@ -161,8 +159,8 @@ export function buildExecutionContext(args) {
161
159
  }
162
160
  // FIXME: https://github.com/graphql/graphql-js/issues/2203
163
161
  /* c8 ignore next */
164
- const variableDefinitions = (_b = operation.variableDefinitions) !== null && _b !== void 0 ? _b : [];
165
- const coercedVariableValues = getVariableValues(schema, variableDefinitions, rawVariableValues !== null && rawVariableValues !== void 0 ? rawVariableValues : {}, {
162
+ const variableDefinitions = operation.variableDefinitions ?? [];
163
+ const coercedVariableValues = getVariableValues(schema, variableDefinitions, rawVariableValues ?? {}, {
166
164
  maxErrors: 50,
167
165
  });
168
166
  if (coercedVariableValues.errors) {
@@ -175,9 +173,9 @@ export function buildExecutionContext(args) {
175
173
  contextValue,
176
174
  operation,
177
175
  variableValues: coercedVariableValues.coerced,
178
- fieldResolver: fieldResolver !== null && fieldResolver !== void 0 ? fieldResolver : defaultFieldResolver,
179
- typeResolver: typeResolver !== null && typeResolver !== void 0 ? typeResolver : defaultTypeResolver,
180
- subscribeFieldResolver: subscribeFieldResolver !== null && subscribeFieldResolver !== void 0 ? subscribeFieldResolver : defaultFieldResolver,
176
+ fieldResolver: fieldResolver ?? defaultFieldResolver,
177
+ typeResolver: typeResolver ?? defaultTypeResolver,
178
+ subscribeFieldResolver: subscribeFieldResolver ?? defaultFieldResolver,
181
179
  subsequentPayloads: new Set(),
182
180
  errors: [],
183
181
  };
@@ -276,14 +274,13 @@ function executeFields(exeContext, parentType, sourceValue, path, fields, asyncP
276
274
  * serialize scalars, or execute the sub-selection-set for objects.
277
275
  */
278
276
  function executeField(exeContext, parentType, source, fieldNodes, path, asyncPayloadRecord) {
279
- var _a, _b;
280
- const errors = (_a = asyncPayloadRecord === null || asyncPayloadRecord === void 0 ? void 0 : asyncPayloadRecord.errors) !== null && _a !== void 0 ? _a : exeContext.errors;
277
+ const errors = asyncPayloadRecord?.errors ?? exeContext.errors;
281
278
  const fieldDef = getFieldDef(exeContext.schema, parentType, fieldNodes[0]);
282
279
  if (!fieldDef) {
283
280
  return;
284
281
  }
285
282
  const returnType = fieldDef.type;
286
- const resolveFn = (_b = fieldDef.resolve) !== null && _b !== void 0 ? _b : exeContext.fieldResolver;
283
+ const resolveFn = fieldDef.resolve ?? exeContext.fieldResolver;
287
284
  const info = buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path);
288
285
  // Get the resolve function, regardless of if its result is normal or abrupt (error).
289
286
  try {
@@ -445,8 +442,7 @@ function getStreamValues(exeContext, fieldNodes, path) {
445
442
  * recursively until all the results are completed.
446
443
  */
447
444
  async function completeAsyncIteratorValue(exeContext, itemType, fieldNodes, info, path, iterator, asyncPayloadRecord) {
448
- var _a;
449
- const errors = (_a = asyncPayloadRecord === null || asyncPayloadRecord === void 0 ? void 0 : asyncPayloadRecord.errors) !== null && _a !== void 0 ? _a : exeContext.errors;
445
+ const errors = asyncPayloadRecord?.errors ?? exeContext.errors;
450
446
  const stream = getStreamValues(exeContext, fieldNodes, path);
451
447
  let containsPromise = false;
452
448
  const completedResults = [];
@@ -481,9 +477,8 @@ async function completeAsyncIteratorValue(exeContext, itemType, fieldNodes, info
481
477
  * inner type
482
478
  */
483
479
  function completeListValue(exeContext, returnType, fieldNodes, info, path, result, asyncPayloadRecord) {
484
- var _a;
485
480
  const itemType = returnType.ofType;
486
- const errors = (_a = asyncPayloadRecord === null || asyncPayloadRecord === void 0 ? void 0 : asyncPayloadRecord.errors) !== null && _a !== void 0 ? _a : exeContext.errors;
481
+ const errors = asyncPayloadRecord?.errors ?? exeContext.errors;
487
482
  if (isAsyncIterable(result)) {
488
483
  const iterator = result[Symbol.asyncIterator]();
489
484
  return completeAsyncIteratorValue(exeContext, itemType, fieldNodes, info, path, iterator, asyncPayloadRecord);
@@ -566,8 +561,7 @@ function completeLeafValue(returnType, result) {
566
561
  * of that value, then complete the value for that type.
567
562
  */
568
563
  function completeAbstractValue(exeContext, returnType, fieldNodes, info, path, result, asyncPayloadRecord) {
569
- var _a;
570
- const resolveTypeFn = (_a = returnType.resolveType) !== null && _a !== void 0 ? _a : exeContext.typeResolver;
564
+ const resolveTypeFn = returnType.resolveType ?? exeContext.typeResolver;
571
565
  const contextValue = exeContext.contextValue;
572
566
  const runtimeType = resolveTypeFn(result, contextValue, info, returnType);
573
567
  if (isPromise(runtimeType)) {
@@ -735,12 +729,11 @@ export function subscribe(args) {
735
729
  if (!('schema' in exeContext)) {
736
730
  return {
737
731
  errors: exeContext.map(e => {
738
- var _a;
739
732
  Object.defineProperty(e, 'extensions', {
740
733
  value: {
741
734
  ...e.extensions,
742
735
  http: {
743
- ...(_a = e.extensions) === null || _a === void 0 ? void 0 : _a['http'],
736
+ ...e.extensions?.['http'],
744
737
  status: 400,
745
738
  },
746
739
  },
@@ -830,7 +823,6 @@ function createSourceEventStreamImpl(exeContext) {
830
823
  }
831
824
  }
832
825
  function executeSubscription(exeContext) {
833
- var _a;
834
826
  const { schema, fragments, operation, variableValues, rootValue } = exeContext;
835
827
  const rootType = schema.getSubscriptionType();
836
828
  if (rootType == null) {
@@ -857,7 +849,7 @@ function executeSubscription(exeContext) {
857
849
  const contextValue = exeContext.contextValue;
858
850
  // Call the `subscribe()` resolver or the default resolver to produce an
859
851
  // AsyncIterable yielding raw payloads.
860
- const resolveFn = (_a = fieldDef.subscribe) !== null && _a !== void 0 ? _a : exeContext.subscribeFieldResolver;
852
+ const resolveFn = fieldDef.subscribe ?? exeContext.subscribeFieldResolver;
861
853
  const result = resolveFn(rootValue, args, contextValue, info);
862
854
  if (isPromise(result)) {
863
855
  return result.then(assertEventStream).then(undefined, error => {
@@ -994,7 +986,7 @@ async function executeStreamIteratorItem(iterator, exeContext, fieldNodes, info,
994
986
  }
995
987
  async function executeStreamIterator(initialIndex, iterator, exeContext, fieldNodes, info, itemType, path, label, parentContext) {
996
988
  let index = initialIndex;
997
- let previousAsyncPayloadRecord = parentContext !== null && parentContext !== void 0 ? parentContext : undefined;
989
+ let previousAsyncPayloadRecord = parentContext ?? undefined;
998
990
  while (true) {
999
991
  const itemPath = addPath(path, index, undefined);
1000
992
  const asyncPayloadRecord = new StreamRecord({
@@ -1013,7 +1005,7 @@ async function executeStreamIterator(initialIndex, iterator, exeContext, fieldNo
1013
1005
  filterSubsequentPayloads(exeContext, path, asyncPayloadRecord);
1014
1006
  asyncPayloadRecord.addItems(null);
1015
1007
  // entire stream has errored and bubbled upwards
1016
- if (iterator === null || iterator === void 0 ? void 0 : iterator.return) {
1008
+ if (iterator?.return) {
1017
1009
  iterator.return().catch(() => {
1018
1010
  // ignore errors
1019
1011
  });
@@ -1043,7 +1035,6 @@ async function executeStreamIterator(initialIndex, iterator, exeContext, fieldNo
1043
1035
  function filterSubsequentPayloads(exeContext, nullPath, currentAsyncRecord) {
1044
1036
  const nullPathArray = pathToArray(nullPath);
1045
1037
  exeContext.subsequentPayloads.forEach(asyncRecord => {
1046
- var _a;
1047
1038
  if (asyncRecord === currentAsyncRecord) {
1048
1039
  // don't remove payload from where error originates
1049
1040
  return;
@@ -1055,7 +1046,7 @@ function filterSubsequentPayloads(exeContext, nullPath, currentAsyncRecord) {
1055
1046
  }
1056
1047
  }
1057
1048
  // asyncRecord path points to nulled error field
1058
- if (isStreamPayload(asyncRecord) && ((_a = asyncRecord.iterator) === null || _a === void 0 ? void 0 : _a.return)) {
1049
+ if (isStreamPayload(asyncRecord) && asyncRecord.iterator?.return) {
1059
1050
  asyncRecord.iterator.return().catch(() => {
1060
1051
  // ignore error
1061
1052
  });
@@ -1081,7 +1072,7 @@ function getCompletedIncrementalResults(exeContext) {
1081
1072
  }
1082
1073
  else {
1083
1074
  const data = asyncPayloadRecord.data;
1084
- incrementalResult.data = data !== null && data !== void 0 ? data : null;
1075
+ incrementalResult.data = data ?? null;
1085
1076
  }
1086
1077
  incrementalResult.path = asyncPayloadRecord.path;
1087
1078
  if (asyncPayloadRecord.label) {
@@ -1121,8 +1112,7 @@ function yieldSubsequentPayloads(exeContext) {
1121
1112
  function returnStreamIterators() {
1122
1113
  const promises = [];
1123
1114
  exeContext.subsequentPayloads.forEach(asyncPayloadRecord => {
1124
- var _a;
1125
- if (isStreamPayload(asyncPayloadRecord) && ((_a = asyncPayloadRecord.iterator) === null || _a === void 0 ? void 0 : _a.return)) {
1115
+ if (isStreamPayload(asyncPayloadRecord) && asyncPayloadRecord.iterator?.return) {
1126
1116
  promises.push(asyncPayloadRecord.iterator.return());
1127
1117
  }
1128
1118
  });
@@ -1166,13 +1156,12 @@ class DeferredFragmentRecord {
1166
1156
  });
1167
1157
  }
1168
1158
  addData(data) {
1169
- var _a, _b, _c;
1170
- const parentData = (_a = this.parentContext) === null || _a === void 0 ? void 0 : _a.promise;
1159
+ const parentData = this.parentContext?.promise;
1171
1160
  if (parentData) {
1172
- (_b = this._resolve) === null || _b === void 0 ? void 0 : _b.call(this, parentData.then(() => data));
1161
+ this._resolve?.(parentData.then(() => data));
1173
1162
  return;
1174
1163
  }
1175
- (_c = this._resolve) === null || _c === void 0 ? void 0 : _c.call(this, data);
1164
+ this._resolve?.(data);
1176
1165
  }
1177
1166
  }
1178
1167
  class StreamRecord {
@@ -1198,13 +1187,12 @@ class StreamRecord {
1198
1187
  });
1199
1188
  }
1200
1189
  addItems(items) {
1201
- var _a, _b, _c;
1202
- const parentData = (_a = this.parentContext) === null || _a === void 0 ? void 0 : _a.promise;
1190
+ const parentData = this.parentContext?.promise;
1203
1191
  if (parentData) {
1204
- (_b = this._resolve) === null || _b === void 0 ? void 0 : _b.call(this, parentData.then(() => items));
1192
+ this._resolve?.(parentData.then(() => items));
1205
1193
  return;
1206
1194
  }
1207
- (_c = this._resolve) === null || _c === void 0 ? void 0 : _c.call(this, items);
1195
+ this._resolve?.(items);
1208
1196
  }
1209
1197
  setIsCompletedIterator() {
1210
1198
  this.isCompletedIterator = true;
@@ -68,15 +68,13 @@ export function flattenAsyncIterable(iterable) {
68
68
  return {
69
69
  next,
70
70
  async return() {
71
- var _a, _b;
72
71
  done = true;
73
- await Promise.all([(_a = currentNestedIterator === null || currentNestedIterator === void 0 ? void 0 : currentNestedIterator.return) === null || _a === void 0 ? void 0 : _a.call(currentNestedIterator), (_b = topIterator.return) === null || _b === void 0 ? void 0 : _b.call(topIterator)]);
72
+ await Promise.all([currentNestedIterator?.return?.(), topIterator.return?.()]);
74
73
  return { value: undefined, done: true };
75
74
  },
76
75
  async throw(error) {
77
- var _a, _b;
78
76
  done = true;
79
- await Promise.all([(_a = currentNestedIterator === null || currentNestedIterator === void 0 ? void 0 : currentNestedIterator.throw) === null || _a === void 0 ? void 0 : _a.call(currentNestedIterator, error), (_b = topIterator.throw) === null || _b === void 0 ? void 0 : _b.call(topIterator, error)]);
77
+ await Promise.all([currentNestedIterator?.throw?.(error), topIterator.throw?.(error)]);
80
78
  /* c8 ignore next */
81
79
  throw error;
82
80
  },
@@ -11,7 +11,7 @@ import { createGraphQLError, hasOwnProperty, inspect, printPathArray } from '@gr
11
11
  */
12
12
  export function getVariableValues(schema, varDefNodes, inputs, options) {
13
13
  const errors = [];
14
- const maxErrors = options === null || options === void 0 ? void 0 : options.maxErrors;
14
+ const maxErrors = options?.maxErrors;
15
15
  try {
16
16
  const coerced = coerceVariableValues(schema, varDefNodes, inputs, error => {
17
17
  if (maxErrors != null && errors.length >= maxErrors) {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@graphql-tools/executor",
3
- "version": "1.0.0-rc-20230519104353-b09f3180",
3
+ "version": "1.0.0",
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
9
  "@repeaterjs/repeater": "^3.0.4",
10
- "@graphql-tools/utils": "10.0.0-rc-20230519104353-b09f3180",
10
+ "@graphql-tools/utils": "^10.0.0",
11
11
  "@graphql-typed-document-node/core": "3.2.0",
12
12
  "tslib": "^2.4.0",
13
13
  "value-or-promise": "^1.0.12"