@graphql-tools/delegate 7.1.3-alpha-3bf9d67c.0 → 7.1.3

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/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { cloneSchema, serializeInputValue, updateArgument, collectFields, relocatedError, mergeDeep, getResponseKeyFromInfo, implementsAbstractType, mapAsyncIterator } from '@graphql-tools/utils';
2
- import { Kind, typeFromAST, GraphQLError, responsePathAsArray, getNamedType, getNullableType, isLeafType, isCompositeType, isListType, isAbstractType, locatedError, defaultFieldResolver, TypeInfo, visit, visitWithTypeInfo, print, isInterfaceType, isObjectType, TypeNameMetaFieldDef, getOperationAST, subscribe, validate, execute } from 'graphql';
2
+ import { Kind, typeFromAST, GraphQLError, locatedError, responsePathAsArray, getNamedType, getNullableType, isLeafType, isCompositeType, isListType, isAbstractType, defaultFieldResolver, TypeInfo, visit, visitWithTypeInfo, print, isInterfaceType, isObjectType, TypeNameMetaFieldDef, getOperationAST, subscribe, validate, execute } from 'graphql';
3
3
  import AggregateError from '@ardatan/aggregate-error';
4
4
  import isPromise from 'is-promise';
5
5
  import { getBatchingExecutor } from '@graphql-tools/batch-execute';
@@ -177,7 +177,7 @@ function mergeExternalObjects(schema, path, typeName, target, sources, selection
177
177
  const results = [];
178
178
  let errors = [];
179
179
  sources.forEach((source, index) => {
180
- if (source instanceof GraphQLError || source === null) {
180
+ if (source instanceof Error || source === null) {
181
181
  const selectionSet = selectionSets[index];
182
182
  const fieldNodes = collectFields({
183
183
  schema,
@@ -186,8 +186,15 @@ function mergeExternalObjects(schema, path, typeName, target, sources, selection
186
186
  }, schema.getType(typeName), selectionSet, Object.create(null), Object.create(null));
187
187
  const nullResult = {};
188
188
  Object.keys(fieldNodes).forEach(responseKey => {
189
- nullResult[responseKey] =
190
- source instanceof GraphQLError ? relocatedError(source, path.concat([responseKey])) : null;
189
+ if (source instanceof GraphQLError) {
190
+ nullResult[responseKey] = relocatedError(source, path.concat([responseKey]));
191
+ }
192
+ else if (source instanceof Error) {
193
+ nullResult[responseKey] = locatedError(source, fieldNodes[responseKey], path.concat([responseKey]));
194
+ }
195
+ else {
196
+ nullResult[responseKey] = null;
197
+ }
191
198
  });
192
199
  results.push(nullResult);
193
200
  }