@graphql-tools/delegate 8.5.2 → 8.5.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.js CHANGED
@@ -708,20 +708,21 @@ async function executeDelegationStage(mergedTypeInfo, delegationMap, object, con
708
708
  const combinedErrors = object[UNPATHED_ERRORS_SYMBOL];
709
709
  const path = graphql.responsePathAsArray(info.path);
710
710
  const combinedFieldSubschemaMap = object[FIELD_SUBSCHEMA_MAP_SYMBOL];
711
- const type = info.schema.getType(object.__typename);
712
- await Promise.all([...delegationMap.entries()].map(async ([s, selectionSet]) => {
711
+ await Promise.all([...delegationMap.entries()].map(async ([subschema, selectionSet]) => {
713
712
  var _a;
714
- const resolver = mergedTypeInfo.resolvers.get(s);
713
+ const schema = subschema.transformedSchema || info.schema;
714
+ const type = schema.getType(object.__typename);
715
+ const resolver = mergedTypeInfo.resolvers.get(subschema);
715
716
  if (resolver) {
716
717
  let source;
717
718
  try {
718
- source = await resolver(object, context, info, s, selectionSet);
719
+ source = await resolver(object, context, info, subschema, selectionSet, undefined, type);
719
720
  }
720
721
  catch (error) {
721
722
  source = error;
722
723
  }
723
724
  if (source instanceof Error || source == null) {
724
- const fieldNodeResponseKeyMap = utils.collectFields(info.schema, {}, {}, type, selectionSet, new Map(), new Set());
725
+ const fieldNodeResponseKeyMap = utils.collectFields(schema, EMPTY_OBJECT, EMPTY_OBJECT, type, selectionSet, new Map(), new Set());
725
726
  const nullResult = {};
726
727
  for (const [responseKey, fieldNodes] of fieldNodeResponseKeyMap) {
727
728
  const combinedPath = [...path, responseKey];
package/index.mjs CHANGED
@@ -704,20 +704,21 @@ async function executeDelegationStage(mergedTypeInfo, delegationMap, object, con
704
704
  const combinedErrors = object[UNPATHED_ERRORS_SYMBOL];
705
705
  const path = responsePathAsArray(info.path);
706
706
  const combinedFieldSubschemaMap = object[FIELD_SUBSCHEMA_MAP_SYMBOL];
707
- const type = info.schema.getType(object.__typename);
708
- await Promise.all([...delegationMap.entries()].map(async ([s, selectionSet]) => {
707
+ await Promise.all([...delegationMap.entries()].map(async ([subschema, selectionSet]) => {
709
708
  var _a;
710
- const resolver = mergedTypeInfo.resolvers.get(s);
709
+ const schema = subschema.transformedSchema || info.schema;
710
+ const type = schema.getType(object.__typename);
711
+ const resolver = mergedTypeInfo.resolvers.get(subschema);
711
712
  if (resolver) {
712
713
  let source;
713
714
  try {
714
- source = await resolver(object, context, info, s, selectionSet);
715
+ source = await resolver(object, context, info, subschema, selectionSet, undefined, type);
715
716
  }
716
717
  catch (error) {
717
718
  source = error;
718
719
  }
719
720
  if (source instanceof Error || source == null) {
720
- const fieldNodeResponseKeyMap = collectFields(info.schema, {}, {}, type, selectionSet, new Map(), new Set());
721
+ const fieldNodeResponseKeyMap = collectFields(schema, EMPTY_OBJECT, EMPTY_OBJECT, type, selectionSet, new Map(), new Set());
721
722
  const nullResult = {};
722
723
  for (const [responseKey, fieldNodes] of fieldNodeResponseKeyMap) {
723
724
  const combinedPath = [...path, responseKey];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/delegate",
3
- "version": "8.5.2",
3
+ "version": "8.5.3",
4
4
  "description": "A set of utils for faster development of GraphQL tools",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
package/types.d.ts CHANGED
@@ -118,7 +118,7 @@ export interface MergedTypeConfig<K = any, V = any, TContext = Record<string, an
118
118
  }
119
119
  export interface MergedTypeEntryPoint<K = any, V = any, TContext = Record<string, any>> extends MergedTypeResolverOptions<K, V> {
120
120
  selectionSet?: string;
121
- key?: (originalResult: any) => K;
121
+ key?: (originalResult: any) => K | PromiseLike<K>;
122
122
  resolve?: MergedTypeResolver<TContext>;
123
123
  }
124
124
  export interface MergedTypeResolverOptions<K = any, V = any> {
@@ -132,7 +132,7 @@ export interface MergedFieldConfig {
132
132
  computed?: boolean;
133
133
  canonical?: boolean;
134
134
  }
135
- export declare type MergedTypeResolver<TContext = Record<string, any>> = (originalResult: any, context: TContext, info: GraphQLResolveInfo, subschema: GraphQLSchema | SubschemaConfig<any, any, any, TContext>, selectionSet: SelectionSetNode, key?: any) => any;
135
+ export declare type MergedTypeResolver<TContext = Record<string, any>> = (originalResult: any, context: TContext, info: GraphQLResolveInfo, subschema: Subschema<any, any, any, TContext>, selectionSet: SelectionSetNode, key: any | undefined, type: GraphQLOutputType) => any;
136
136
  export interface StitchingInfo<TContext = Record<string, any>> {
137
137
  subschemaMap: Map<GraphQLSchema | SubschemaConfig<any, any, any, TContext>, Subschema<any, any, any, TContext>>;
138
138
  fieldNodesByType: Record<string, Array<FieldNode>>;