@graphql-tools/delegate 10.1.3 → 10.2.0-alpha-7f3ef56a9fcb3332fc9ec75c9dfeea123b8123e6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @graphql-tools/delegate
2
2
 
3
+ ## 10.2.0-alpha-7f3ef56a9fcb3332fc9ec75c9dfeea123b8123e6
4
+
5
+ ### Minor Changes
6
+
7
+ - [#148](https://github.com/graphql-hive/gateway/pull/148) [`7f3ef56`](https://github.com/graphql-hive/gateway/commit/7f3ef56a9fcb3332fc9ec75c9dfeea123b8123e6) Thanks [@ardatan](https://github.com/ardatan)! - Introduce \`onDelegationPlan\` and \`onDelegationStageExecuteDone\` hooks
8
+
3
9
  ## 10.1.3
4
10
 
5
11
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -110,7 +110,9 @@ function mergeFields(mergedTypeInfo, object, sourceSubschema, context, info) {
110
110
  sourceSubschema,
111
111
  info.variableValues != null && Object.keys(info.variableValues).length > 0 ? info.variableValues : EMPTY_OBJECT,
112
112
  info.fragments != null && Object.keys(info.fragments).length > 0 ? info.fragments : EMPTY_OBJECT,
113
- info.fieldNodes?.length ? info.fieldNodes.length === 1 && info.fieldNodes[0] ? getActualFieldNodes(info.fieldNodes[0]) : info.fieldNodes : EMPTY_ARRAY
113
+ info.fieldNodes?.length ? info.fieldNodes.length === 1 && info.fieldNodes[0] ? getActualFieldNodes(info.fieldNodes[0]) : info.fieldNodes : EMPTY_ARRAY,
114
+ context,
115
+ info
114
116
  );
115
117
  const leftOver = leftOverByDelegationPlan.get(delegationMaps);
116
118
  if (leftOver) {
@@ -213,7 +215,7 @@ function handleResolverResult(resolverResult, subschema, selectionSet, object, c
213
215
  }
214
216
  function executeDelegationStage(mergedTypeInfo, delegationMap, object, context, info) {
215
217
  const combinedErrors = object[UNPATHED_ERRORS_SYMBOL];
216
- const path = graphql.responsePathAsArray(info.path);
218
+ const path = utils.pathToArray(info.path);
217
219
  const combinedFieldSubschemaMap = object[FIELD_SUBSCHEMA_MAP_SYMBOL];
218
220
  const jobs = [];
219
221
  for (const [subschema, selectionSet] of delegationMap) {
package/dist/index.d.cts CHANGED
@@ -68,7 +68,7 @@ interface ICreateRequest {
68
68
  context?: any;
69
69
  info?: GraphQLResolveInfo;
70
70
  }
71
- type DelegationPlanBuilder = (schema: GraphQLSchema, sourceSubschema: Subschema<any, any, any, any>, variableValues: Record<string, any>, fragments: Record<string, FragmentDefinitionNode>, fieldNodes: FieldNode[]) => Array<Map<Subschema, SelectionSetNode>>;
71
+ type DelegationPlanBuilder = (schema: GraphQLSchema, sourceSubschema: Subschema<any, any, any, any>, variableValues: Record<string, any>, fragments: Record<string, FragmentDefinitionNode>, fieldNodes: FieldNode[], context?: any, info?: GraphQLResolveInfo) => Array<Map<Subschema, SelectionSetNode>>;
72
72
  interface MergedTypeInfo<TContext = Record<string, any>> {
73
73
  typeName: string;
74
74
  selectionSet?: SelectionSetNode;
@@ -80,6 +80,7 @@ interface MergedTypeInfo<TContext = Record<string, any>> {
80
80
  fieldSelectionSets: Map<Subschema<any, any, any, TContext>, Record<string, SelectionSetNode>>;
81
81
  resolvers: Map<Subschema<any, any, any, TContext>, MergedTypeResolver<TContext>>;
82
82
  delegationPlanBuilder: DelegationPlanBuilder;
83
+ nonMemoizedDelegationPlanBuilder: DelegationPlanBuilder;
83
84
  }
84
85
  interface ICreateProxyingResolverOptions<TContext = Record<string, any>> {
85
86
  subschemaConfig: SubschemaConfig<any, any, any, TContext>;
package/dist/index.d.ts CHANGED
@@ -68,7 +68,7 @@ interface ICreateRequest {
68
68
  context?: any;
69
69
  info?: GraphQLResolveInfo;
70
70
  }
71
- type DelegationPlanBuilder = (schema: GraphQLSchema, sourceSubschema: Subschema<any, any, any, any>, variableValues: Record<string, any>, fragments: Record<string, FragmentDefinitionNode>, fieldNodes: FieldNode[]) => Array<Map<Subschema, SelectionSetNode>>;
71
+ type DelegationPlanBuilder = (schema: GraphQLSchema, sourceSubschema: Subschema<any, any, any, any>, variableValues: Record<string, any>, fragments: Record<string, FragmentDefinitionNode>, fieldNodes: FieldNode[], context?: any, info?: GraphQLResolveInfo) => Array<Map<Subschema, SelectionSetNode>>;
72
72
  interface MergedTypeInfo<TContext = Record<string, any>> {
73
73
  typeName: string;
74
74
  selectionSet?: SelectionSetNode;
@@ -80,6 +80,7 @@ interface MergedTypeInfo<TContext = Record<string, any>> {
80
80
  fieldSelectionSets: Map<Subschema<any, any, any, TContext>, Record<string, SelectionSetNode>>;
81
81
  resolvers: Map<Subschema<any, any, any, TContext>, MergedTypeResolver<TContext>>;
82
82
  delegationPlanBuilder: DelegationPlanBuilder;
83
+ nonMemoizedDelegationPlanBuilder: DelegationPlanBuilder;
83
84
  }
84
85
  interface ICreateProxyingResolverOptions<TContext = Record<string, any>> {
85
86
  subschemaConfig: SubschemaConfig<any, any, any, TContext>;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { memoize2, memoize1, isPromise, collectFields, relocatedError, mergeDeep, getResponseKeyFromInfo, getDefinedRootType, createVariableNameGenerator, updateArgument, serializeInputValue, createGraphQLError, implementsAbstractType, getRootTypeNames, getOperationASTFromRequest, isAsyncIterable, mapAsyncIterator, memoize4 } from '@graphql-tools/utils';
2
- import { GraphQLError, locatedError, isAbstractType, responsePathAsArray, getNullableType, isLeafType, isCompositeType, isListType, Kind, versionInfo, TypeInfo, visit, visitWithTypeInfo, isObjectType, isInterfaceType, TypeNameMetaFieldDef, isUnionType, getNamedType, isNullableType, typeFromAST, defaultFieldResolver, validate } from 'graphql';
1
+ import { memoize2, memoize1, isPromise, collectFields, relocatedError, mergeDeep, pathToArray, getResponseKeyFromInfo, getDefinedRootType, createVariableNameGenerator, updateArgument, serializeInputValue, createGraphQLError, implementsAbstractType, getRootTypeNames, getOperationASTFromRequest, isAsyncIterable, mapAsyncIterator, memoize4 } from '@graphql-tools/utils';
2
+ import { GraphQLError, locatedError, isAbstractType, getNullableType, isLeafType, isCompositeType, isListType, responsePathAsArray, Kind, versionInfo, TypeInfo, visit, visitWithTypeInfo, isObjectType, isInterfaceType, TypeNameMetaFieldDef, isUnionType, getNamedType, isNullableType, typeFromAST, defaultFieldResolver, validate } from 'graphql';
3
3
  import { CRITICAL_ERROR, normalizedExecutor } from '@graphql-tools/executor';
4
4
  import { getBatchingExecutor } from '@graphql-tools/batch-execute';
5
5
  import { Repeater } from '@repeaterjs/repeater';
@@ -108,7 +108,9 @@ function mergeFields(mergedTypeInfo, object, sourceSubschema, context, info) {
108
108
  sourceSubschema,
109
109
  info.variableValues != null && Object.keys(info.variableValues).length > 0 ? info.variableValues : EMPTY_OBJECT,
110
110
  info.fragments != null && Object.keys(info.fragments).length > 0 ? info.fragments : EMPTY_OBJECT,
111
- info.fieldNodes?.length ? info.fieldNodes.length === 1 && info.fieldNodes[0] ? getActualFieldNodes(info.fieldNodes[0]) : info.fieldNodes : EMPTY_ARRAY
111
+ info.fieldNodes?.length ? info.fieldNodes.length === 1 && info.fieldNodes[0] ? getActualFieldNodes(info.fieldNodes[0]) : info.fieldNodes : EMPTY_ARRAY,
112
+ context,
113
+ info
112
114
  );
113
115
  const leftOver = leftOverByDelegationPlan.get(delegationMaps);
114
116
  if (leftOver) {
@@ -211,7 +213,7 @@ function handleResolverResult(resolverResult, subschema, selectionSet, object, c
211
213
  }
212
214
  function executeDelegationStage(mergedTypeInfo, delegationMap, object, context, info) {
213
215
  const combinedErrors = object[UNPATHED_ERRORS_SYMBOL];
214
- const path = responsePathAsArray(info.path);
216
+ const path = pathToArray(info.path);
215
217
  const combinedFieldSubschemaMap = object[FIELD_SUBSCHEMA_MAP_SYMBOL];
216
218
  const jobs = [];
217
219
  for (const [subschema, selectionSet] of delegationMap) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/delegate",
3
- "version": "10.1.3",
3
+ "version": "10.2.0-alpha-7f3ef56a9fcb3332fc9ec75c9dfeea123b8123e6",
4
4
  "type": "module",
5
5
  "description": "A set of utils for faster development of GraphQL tools",
6
6
  "repository": {