@graphql-tools/delegate 12.0.14 → 12.0.15-alpha-5e89a90a725d4456ffc327ff7d543f8edd6e8f14
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 +7 -0
- package/dist/index.cjs +33 -41
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +34 -42
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @graphql-tools/delegate
|
|
2
2
|
|
|
3
|
+
## 12.0.15-alpha-5e89a90a725d4456ffc327ff7d543f8edd6e8f14
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
- [#2273](https://github.com/graphql-hive/gateway/pull/2273) [`5ec0367`](https://github.com/graphql-hive/gateway/commit/5ec0367e9f98207d0f61ba87e7d9c660533808c9) Thanks [@ardatan](https://github.com/ardatan)! - Support additional type definitions, resolvers and custom type merging configuration in Rust Query Planner mode
|
|
9
|
+
|
|
3
10
|
## 12.0.14
|
|
4
11
|
### Patch Changes
|
|
5
12
|
|
package/dist/index.cjs
CHANGED
|
@@ -686,43 +686,35 @@ function finalizeGatewayDocument(targetSchema, fragments, operations, onOverlapp
|
|
|
686
686
|
kind: graphql.Kind.DOCUMENT,
|
|
687
687
|
definitions: [...newOperations, ...newFragments]
|
|
688
688
|
};
|
|
689
|
-
const
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
const
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
const
|
|
700
|
-
if (
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
selectionSet: {
|
|
710
|
-
kind: graphql.Kind.SELECTION_SET,
|
|
711
|
-
selections: [
|
|
712
|
-
...providedSelection.selections,
|
|
713
|
-
...fieldNode.selectionSet?.selections ?? []
|
|
714
|
-
]
|
|
715
|
-
}
|
|
716
|
-
};
|
|
689
|
+
const typeInfo = getTypeInfo(targetSchema);
|
|
690
|
+
newDocument = graphql.visit(
|
|
691
|
+
newDocument,
|
|
692
|
+
graphql.visitWithTypeInfo(typeInfo, {
|
|
693
|
+
[graphql.Kind.FIELD](fieldNode) {
|
|
694
|
+
const parentType = typeInfo.getParentType();
|
|
695
|
+
if (parentType) {
|
|
696
|
+
const parentTypeName = parentType.name;
|
|
697
|
+
const typeConfig = delegationContext?.subschemaConfig?.merge?.[parentTypeName];
|
|
698
|
+
if (typeConfig) {
|
|
699
|
+
const providedSelection = typeConfig.fields?.[fieldNode.name.value]?.provides;
|
|
700
|
+
if (providedSelection) {
|
|
701
|
+
return {
|
|
702
|
+
...fieldNode,
|
|
703
|
+
selectionSet: {
|
|
704
|
+
kind: graphql.Kind.SELECTION_SET,
|
|
705
|
+
selections: [
|
|
706
|
+
...providedSelection.selections,
|
|
707
|
+
...fieldNode.selectionSet?.selections ?? []
|
|
708
|
+
]
|
|
717
709
|
}
|
|
718
|
-
}
|
|
710
|
+
};
|
|
719
711
|
}
|
|
720
712
|
}
|
|
721
|
-
return fieldNode;
|
|
722
713
|
}
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
714
|
+
return fieldNode;
|
|
715
|
+
}
|
|
716
|
+
})
|
|
717
|
+
);
|
|
726
718
|
return {
|
|
727
719
|
usedVariables,
|
|
728
720
|
newDocument
|
|
@@ -2582,14 +2574,15 @@ function delegateToSchema(options) {
|
|
|
2582
2574
|
const {
|
|
2583
2575
|
info,
|
|
2584
2576
|
schema,
|
|
2585
|
-
rootValue = schema.rootValue ?? info
|
|
2586
|
-
operationName = info
|
|
2587
|
-
operation = getDelegatingOperation(info.parentType, info.schema),
|
|
2588
|
-
fieldName = info
|
|
2577
|
+
rootValue = schema.rootValue ?? info?.rootValue,
|
|
2578
|
+
operationName = info?.operation.name?.value,
|
|
2579
|
+
operation = info ? getDelegatingOperation(info.parentType, info.schema) : graphql.OperationTypeNode.QUERY,
|
|
2580
|
+
fieldName = info?.fieldName,
|
|
2589
2581
|
selectionSet,
|
|
2590
|
-
fieldNodes = info
|
|
2582
|
+
fieldNodes = info?.fieldNodes,
|
|
2591
2583
|
context,
|
|
2592
|
-
args
|
|
2584
|
+
args,
|
|
2585
|
+
fragments = info ? getFragmentDefinitions(info) : void 0
|
|
2593
2586
|
} = options;
|
|
2594
2587
|
let targetSchema;
|
|
2595
2588
|
if (isSubschema(schema)) {
|
|
@@ -2597,7 +2590,7 @@ function delegateToSchema(options) {
|
|
|
2597
2590
|
} else if (graphql.isSchema(schema)) {
|
|
2598
2591
|
targetSchema = schema;
|
|
2599
2592
|
} else {
|
|
2600
|
-
const stitchingInfo = info
|
|
2593
|
+
const stitchingInfo = info?.schema.extensions?.["stitchingInfo"];
|
|
2601
2594
|
const subschema = stitchingInfo?.subschemaMap.get(schema);
|
|
2602
2595
|
if (subschema != null) {
|
|
2603
2596
|
targetSchema = subschema.transformedSchema;
|
|
@@ -2605,7 +2598,6 @@ function delegateToSchema(options) {
|
|
|
2605
2598
|
targetSchema = applySchemaTransforms(schema.schema, schema);
|
|
2606
2599
|
}
|
|
2607
2600
|
}
|
|
2608
|
-
const fragments = info ? getFragmentDefinitions(info) : void 0;
|
|
2609
2601
|
const request = createRequest({
|
|
2610
2602
|
subgraphName: schema.name,
|
|
2611
2603
|
fragments,
|
package/dist/index.d.cts
CHANGED
|
@@ -51,6 +51,7 @@ interface IDelegateToSchemaOptions<TContext = Record<string, any>, TArgs = Recor
|
|
|
51
51
|
targetSchema?: GraphQLSchema;
|
|
52
52
|
validateRequest?: boolean;
|
|
53
53
|
skipTypeMerging?: boolean;
|
|
54
|
+
fragments?: FragmentDefinitionNode[];
|
|
54
55
|
}
|
|
55
56
|
interface IDelegateRequestOptions<TContext = Record<string, any>, TArgs = Record<string, any>> extends IDelegateToSchemaOptions<TContext, TArgs> {
|
|
56
57
|
request: ExecutionRequest;
|
package/dist/index.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ interface IDelegateToSchemaOptions<TContext = Record<string, any>, TArgs = Recor
|
|
|
51
51
|
targetSchema?: GraphQLSchema;
|
|
52
52
|
validateRequest?: boolean;
|
|
53
53
|
skipTypeMerging?: boolean;
|
|
54
|
+
fragments?: FragmentDefinitionNode[];
|
|
54
55
|
}
|
|
55
56
|
interface IDelegateRequestOptions<TContext = Record<string, any>, TArgs = Record<string, any>> extends IDelegateToSchemaOptions<TContext, TArgs> {
|
|
56
57
|
request: ExecutionRequest;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { memoize2, memoize1, collectFields, relocatedError, mergeDeep, promiseReduce, pathToArray, getResponseKeyFromInfo, memoize3, getDefinedRootType, createGraphQLError, implementsAbstractType, getRootTypeNames, astFromArg, astFromValueUntyped, asArray, isAsyncIterable, getOperationASTFromRequest } from '@graphql-tools/utils';
|
|
2
2
|
export { createDeferred } from '@graphql-tools/utils';
|
|
3
|
-
import { GraphQLError, locatedError, isAbstractType, getNullableType, isLeafType, isCompositeType, isListType, responsePathAsArray, Kind, TypeInfo, versionInfo, visit, visitWithTypeInfo, isNullableType, isUnionType, getNamedType, isObjectType, isInterfaceType, isNonNullType, isInputObjectType, defaultFieldResolver, isSchema, validate } from 'graphql';
|
|
3
|
+
import { GraphQLError, locatedError, isAbstractType, getNullableType, isLeafType, isCompositeType, isListType, responsePathAsArray, Kind, TypeInfo, versionInfo, visit, visitWithTypeInfo, isNullableType, isUnionType, getNamedType, isObjectType, isInterfaceType, isNonNullType, isInputObjectType, defaultFieldResolver, OperationTypeNode, isSchema, validate } from 'graphql';
|
|
4
4
|
import { handleMaybePromise, isPromise, createDeferredPromise, mapAsyncIterator } from '@whatwg-node/promise-helpers';
|
|
5
5
|
import { CRITICAL_ERROR, executorFromSchema } from '@graphql-tools/executor';
|
|
6
6
|
export { executorFromSchema as createDefaultExecutor } from '@graphql-tools/executor';
|
|
@@ -686,43 +686,35 @@ function finalizeGatewayDocument(targetSchema, fragments, operations, onOverlapp
|
|
|
686
686
|
kind: Kind.DOCUMENT,
|
|
687
687
|
definitions: [...newOperations, ...newFragments]
|
|
688
688
|
};
|
|
689
|
-
const
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
const
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
const
|
|
700
|
-
if (
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
selectionSet: {
|
|
710
|
-
kind: Kind.SELECTION_SET,
|
|
711
|
-
selections: [
|
|
712
|
-
...providedSelection.selections,
|
|
713
|
-
...fieldNode.selectionSet?.selections ?? []
|
|
714
|
-
]
|
|
715
|
-
}
|
|
716
|
-
};
|
|
689
|
+
const typeInfo = getTypeInfo(targetSchema);
|
|
690
|
+
newDocument = visit(
|
|
691
|
+
newDocument,
|
|
692
|
+
visitWithTypeInfo(typeInfo, {
|
|
693
|
+
[Kind.FIELD](fieldNode) {
|
|
694
|
+
const parentType = typeInfo.getParentType();
|
|
695
|
+
if (parentType) {
|
|
696
|
+
const parentTypeName = parentType.name;
|
|
697
|
+
const typeConfig = delegationContext?.subschemaConfig?.merge?.[parentTypeName];
|
|
698
|
+
if (typeConfig) {
|
|
699
|
+
const providedSelection = typeConfig.fields?.[fieldNode.name.value]?.provides;
|
|
700
|
+
if (providedSelection) {
|
|
701
|
+
return {
|
|
702
|
+
...fieldNode,
|
|
703
|
+
selectionSet: {
|
|
704
|
+
kind: Kind.SELECTION_SET,
|
|
705
|
+
selections: [
|
|
706
|
+
...providedSelection.selections,
|
|
707
|
+
...fieldNode.selectionSet?.selections ?? []
|
|
708
|
+
]
|
|
717
709
|
}
|
|
718
|
-
}
|
|
710
|
+
};
|
|
719
711
|
}
|
|
720
712
|
}
|
|
721
|
-
return fieldNode;
|
|
722
713
|
}
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
714
|
+
return fieldNode;
|
|
715
|
+
}
|
|
716
|
+
})
|
|
717
|
+
);
|
|
726
718
|
return {
|
|
727
719
|
usedVariables,
|
|
728
720
|
newDocument
|
|
@@ -2582,14 +2574,15 @@ function delegateToSchema(options) {
|
|
|
2582
2574
|
const {
|
|
2583
2575
|
info,
|
|
2584
2576
|
schema,
|
|
2585
|
-
rootValue = schema.rootValue ?? info
|
|
2586
|
-
operationName = info
|
|
2587
|
-
operation = getDelegatingOperation(info.parentType, info.schema),
|
|
2588
|
-
fieldName = info
|
|
2577
|
+
rootValue = schema.rootValue ?? info?.rootValue,
|
|
2578
|
+
operationName = info?.operation.name?.value,
|
|
2579
|
+
operation = info ? getDelegatingOperation(info.parentType, info.schema) : OperationTypeNode.QUERY,
|
|
2580
|
+
fieldName = info?.fieldName,
|
|
2589
2581
|
selectionSet,
|
|
2590
|
-
fieldNodes = info
|
|
2582
|
+
fieldNodes = info?.fieldNodes,
|
|
2591
2583
|
context,
|
|
2592
|
-
args
|
|
2584
|
+
args,
|
|
2585
|
+
fragments = info ? getFragmentDefinitions(info) : void 0
|
|
2593
2586
|
} = options;
|
|
2594
2587
|
let targetSchema;
|
|
2595
2588
|
if (isSubschema(schema)) {
|
|
@@ -2597,7 +2590,7 @@ function delegateToSchema(options) {
|
|
|
2597
2590
|
} else if (isSchema(schema)) {
|
|
2598
2591
|
targetSchema = schema;
|
|
2599
2592
|
} else {
|
|
2600
|
-
const stitchingInfo = info
|
|
2593
|
+
const stitchingInfo = info?.schema.extensions?.["stitchingInfo"];
|
|
2601
2594
|
const subschema = stitchingInfo?.subschemaMap.get(schema);
|
|
2602
2595
|
if (subschema != null) {
|
|
2603
2596
|
targetSchema = subschema.transformedSchema;
|
|
@@ -2605,7 +2598,6 @@ function delegateToSchema(options) {
|
|
|
2605
2598
|
targetSchema = applySchemaTransforms(schema.schema, schema);
|
|
2606
2599
|
}
|
|
2607
2600
|
}
|
|
2608
|
-
const fragments = info ? getFragmentDefinitions(info) : void 0;
|
|
2609
2601
|
const request = createRequest({
|
|
2610
2602
|
subgraphName: schema.name,
|
|
2611
2603
|
fragments,
|
package/package.json
CHANGED