@graphql-mesh/fusion-runtime 1.8.6 → 1.8.7-alpha-971df8ca5edef1a97ddf1332eb144ea01e16342e
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 -1
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +34 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @graphql-mesh/fusion-runtime
|
|
2
2
|
|
|
3
|
+
## 1.8.7-alpha-971df8ca5edef1a97ddf1332eb144ea01e16342e
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
- [#2225](https://github.com/graphql-hive/gateway/pull/2225) [`9d467a8`](https://github.com/graphql-hive/gateway/commit/9d467a839e9d7dc8a236d8b66c519e19c89bd67f) Thanks [@enisdenjo](https://github.com/enisdenjo)! - Inject the @resolveTo directive definition when not present in the composed supergraph SDL
|
|
9
|
+
|
|
3
10
|
## 1.8.6
|
|
4
11
|
### Patch Changes
|
|
5
12
|
|
package/dist/index.cjs
CHANGED
|
@@ -595,13 +595,42 @@ function getStitchingDirectivesTransformerForSubschema() {
|
|
|
595
595
|
});
|
|
596
596
|
return stitchingDirectivesTransformer;
|
|
597
597
|
}
|
|
598
|
+
const RESOLVE_TO_DIRECTIVE_DEF = graphql.parse(
|
|
599
|
+
/* GraphQL */
|
|
600
|
+
`
|
|
601
|
+
scalar ResolveToSourceArgs
|
|
602
|
+
directive @resolveTo(
|
|
603
|
+
requiredSelectionSet: String
|
|
604
|
+
sourceName: String
|
|
605
|
+
sourceTypeName: String
|
|
606
|
+
sourceFieldName: String
|
|
607
|
+
sourceSelectionSet: String
|
|
608
|
+
sourceArgs: ResolveToSourceArgs
|
|
609
|
+
keyField: String
|
|
610
|
+
keysArg: String
|
|
611
|
+
pubsubTopic: String
|
|
612
|
+
filterBy: String
|
|
613
|
+
additionalArgs: ResolveToSourceArgs
|
|
614
|
+
result: String
|
|
615
|
+
resultType: String
|
|
616
|
+
) on FIELD_DEFINITION
|
|
617
|
+
`
|
|
618
|
+
);
|
|
598
619
|
function handleResolveToDirectives(typeDefsOpt, additionalTypeDefs, additionalResolvers) {
|
|
599
|
-
|
|
620
|
+
let mergedTypeDefs = merge.mergeTypeDefs([typeDefsOpt, additionalTypeDefs]);
|
|
621
|
+
let resolveToUsed = false;
|
|
622
|
+
let resolveToDirectiveDefined = false;
|
|
600
623
|
graphql.visit(mergedTypeDefs, {
|
|
624
|
+
[graphql.Kind.DIRECTIVE_DEFINITION](node) {
|
|
625
|
+
if (node.name.value === "resolveTo") {
|
|
626
|
+
resolveToDirectiveDefined = true;
|
|
627
|
+
}
|
|
628
|
+
},
|
|
601
629
|
[graphql.Kind.FIELD_DEFINITION](field, _key, _parent, _path, ancestors) {
|
|
602
630
|
const fieldDirectives = utils.getDirectiveExtensions({ astNode: field });
|
|
603
631
|
const resolveToDirectives = fieldDirectives?.resolveTo;
|
|
604
632
|
if (resolveToDirectives?.length) {
|
|
633
|
+
resolveToUsed = true;
|
|
605
634
|
const targetTypeName = ancestors[ancestors.length - 1].name.value;
|
|
606
635
|
const targetFieldName = field.name.value;
|
|
607
636
|
for (const resolveToDirective of resolveToDirectives) {
|
|
@@ -616,6 +645,9 @@ function handleResolveToDirectives(typeDefsOpt, additionalTypeDefs, additionalRe
|
|
|
616
645
|
}
|
|
617
646
|
}
|
|
618
647
|
});
|
|
648
|
+
if (resolveToUsed && !resolveToDirectiveDefined) {
|
|
649
|
+
mergedTypeDefs = merge.mergeTypeDefs([RESOLVE_TO_DIRECTIVE_DEF, mergedTypeDefs]);
|
|
650
|
+
}
|
|
619
651
|
return mergedTypeDefs;
|
|
620
652
|
}
|
|
621
653
|
const handleFederationSupergraph = function({
|
package/dist/index.d.cts
CHANGED
|
@@ -4,7 +4,6 @@ import { Logger } from '@graphql-hive/logger';
|
|
|
4
4
|
import { TransportContext, TransportEntry, Transport } from '@graphql-mesh/transport-common';
|
|
5
5
|
export { TransportEntry, TransportGetSubgraphExecutor, TransportGetSubgraphExecutorOptions } from '@graphql-mesh/transport-common';
|
|
6
6
|
import { DelegationPlanBuilder, Subschema, MergedTypeResolver, SubschemaConfig } from '@graphql-tools/delegate';
|
|
7
|
-
import * as graphql from 'graphql';
|
|
8
7
|
import { GraphQLSchema, DocumentNode, ExecutionResult, GraphQLError, FragmentDefinitionNode, SelectionNode, SelectionSetNode } from 'graphql';
|
|
9
8
|
import { GraphQLResolveInfo, GraphQLOutputType } from 'graphql/type';
|
|
10
9
|
import { OnDelegateHook } from '@graphql-mesh/types';
|
|
@@ -244,7 +243,7 @@ declare function getTransportEntryMapUsingFusionAndFederationDirectives(unifiedG
|
|
|
244
243
|
|
|
245
244
|
declare const restoreExtraDirectives: (schema: GraphQLSchema) => GraphQLSchema;
|
|
246
245
|
declare function getStitchingDirectivesTransformerForSubschema(): (subschemaConfig: SubschemaConfig) => SubschemaConfig;
|
|
247
|
-
declare function handleResolveToDirectives(typeDefsOpt: TypeSource, additionalTypeDefs: TypeSource, additionalResolvers: IResolvers[]):
|
|
246
|
+
declare function handleResolveToDirectives(typeDefsOpt: TypeSource, additionalTypeDefs: TypeSource, additionalResolvers: IResolvers[]): DocumentNode;
|
|
248
247
|
interface HandleFederationSupergraphResult extends UnifiedGraphHandlerResult {
|
|
249
248
|
getSubschema(subgraphName: string): SubschemaConfig;
|
|
250
249
|
subschemas: SubschemaConfig[];
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { Logger } from '@graphql-hive/logger';
|
|
|
4
4
|
import { TransportContext, TransportEntry, Transport } from '@graphql-mesh/transport-common';
|
|
5
5
|
export { TransportEntry, TransportGetSubgraphExecutor, TransportGetSubgraphExecutorOptions } from '@graphql-mesh/transport-common';
|
|
6
6
|
import { DelegationPlanBuilder, Subschema, MergedTypeResolver, SubschemaConfig } from '@graphql-tools/delegate';
|
|
7
|
-
import * as graphql from 'graphql';
|
|
8
7
|
import { GraphQLSchema, DocumentNode, ExecutionResult, GraphQLError, FragmentDefinitionNode, SelectionNode, SelectionSetNode } from 'graphql';
|
|
9
8
|
import { GraphQLResolveInfo, GraphQLOutputType } from 'graphql/type';
|
|
10
9
|
import { OnDelegateHook } from '@graphql-mesh/types';
|
|
@@ -244,7 +243,7 @@ declare function getTransportEntryMapUsingFusionAndFederationDirectives(unifiedG
|
|
|
244
243
|
|
|
245
244
|
declare const restoreExtraDirectives: (schema: GraphQLSchema) => GraphQLSchema;
|
|
246
245
|
declare function getStitchingDirectivesTransformerForSubschema(): (subschemaConfig: SubschemaConfig) => SubschemaConfig;
|
|
247
|
-
declare function handleResolveToDirectives(typeDefsOpt: TypeSource, additionalTypeDefs: TypeSource, additionalResolvers: IResolvers[]):
|
|
246
|
+
declare function handleResolveToDirectives(typeDefsOpt: TypeSource, additionalTypeDefs: TypeSource, additionalResolvers: IResolvers[]): DocumentNode;
|
|
248
247
|
interface HandleFederationSupergraphResult extends UnifiedGraphHandlerResult {
|
|
249
248
|
getSubschema(subgraphName: string): SubschemaConfig;
|
|
250
249
|
subschemas: SubschemaConfig[];
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { getInContextSDK, getResolverForPubSubOperation, resolveAdditionalResolv
|
|
|
5
5
|
import { getBatchingExecutor } from '@graphql-tools/batch-execute';
|
|
6
6
|
import { getDirectiveExtensions, mapSchema, MapperKind, astFromField, asArray, getDocumentNodeFromSchema, memoize1, isDocumentNode, printSchemaWithDirectives, mergeDeep, isAsyncIterable, createGraphQLError } from '@graphql-tools/utils';
|
|
7
7
|
import { handleMaybePromise, isPromise, mapAsyncIterator } from '@whatwg-node/promise-helpers';
|
|
8
|
-
import { isInterfaceType, Kind, isObjectType, typeFromAST, isOutputType, GraphQLSchema, GraphQLDirective, parseType, visit, GraphQLString, DirectiveLocation, isEnumType, isSchema, buildSchema, buildASTSchema } from 'graphql';
|
|
8
|
+
import { isInterfaceType, Kind, isObjectType, typeFromAST, isOutputType, GraphQLSchema, GraphQLDirective, parseType, visit, GraphQLString, DirectiveLocation, isEnumType, parse, isSchema, buildSchema, buildASTSchema } from 'graphql';
|
|
9
9
|
import { defaultMergedResolver } from '@graphql-tools/delegate';
|
|
10
10
|
import { getStitchedSchemaFromSupergraphSdl } from '@graphql-tools/federation';
|
|
11
11
|
import { mergeTypeDefs } from '@graphql-tools/merge';
|
|
@@ -593,13 +593,42 @@ function getStitchingDirectivesTransformerForSubschema() {
|
|
|
593
593
|
});
|
|
594
594
|
return stitchingDirectivesTransformer;
|
|
595
595
|
}
|
|
596
|
+
const RESOLVE_TO_DIRECTIVE_DEF = parse(
|
|
597
|
+
/* GraphQL */
|
|
598
|
+
`
|
|
599
|
+
scalar ResolveToSourceArgs
|
|
600
|
+
directive @resolveTo(
|
|
601
|
+
requiredSelectionSet: String
|
|
602
|
+
sourceName: String
|
|
603
|
+
sourceTypeName: String
|
|
604
|
+
sourceFieldName: String
|
|
605
|
+
sourceSelectionSet: String
|
|
606
|
+
sourceArgs: ResolveToSourceArgs
|
|
607
|
+
keyField: String
|
|
608
|
+
keysArg: String
|
|
609
|
+
pubsubTopic: String
|
|
610
|
+
filterBy: String
|
|
611
|
+
additionalArgs: ResolveToSourceArgs
|
|
612
|
+
result: String
|
|
613
|
+
resultType: String
|
|
614
|
+
) on FIELD_DEFINITION
|
|
615
|
+
`
|
|
616
|
+
);
|
|
596
617
|
function handleResolveToDirectives(typeDefsOpt, additionalTypeDefs, additionalResolvers) {
|
|
597
|
-
|
|
618
|
+
let mergedTypeDefs = mergeTypeDefs([typeDefsOpt, additionalTypeDefs]);
|
|
619
|
+
let resolveToUsed = false;
|
|
620
|
+
let resolveToDirectiveDefined = false;
|
|
598
621
|
visit(mergedTypeDefs, {
|
|
622
|
+
[Kind.DIRECTIVE_DEFINITION](node) {
|
|
623
|
+
if (node.name.value === "resolveTo") {
|
|
624
|
+
resolveToDirectiveDefined = true;
|
|
625
|
+
}
|
|
626
|
+
},
|
|
599
627
|
[Kind.FIELD_DEFINITION](field, _key, _parent, _path, ancestors) {
|
|
600
628
|
const fieldDirectives = getDirectiveExtensions({ astNode: field });
|
|
601
629
|
const resolveToDirectives = fieldDirectives?.resolveTo;
|
|
602
630
|
if (resolveToDirectives?.length) {
|
|
631
|
+
resolveToUsed = true;
|
|
603
632
|
const targetTypeName = ancestors[ancestors.length - 1].name.value;
|
|
604
633
|
const targetFieldName = field.name.value;
|
|
605
634
|
for (const resolveToDirective of resolveToDirectives) {
|
|
@@ -614,6 +643,9 @@ function handleResolveToDirectives(typeDefsOpt, additionalTypeDefs, additionalRe
|
|
|
614
643
|
}
|
|
615
644
|
}
|
|
616
645
|
});
|
|
646
|
+
if (resolveToUsed && !resolveToDirectiveDefined) {
|
|
647
|
+
mergedTypeDefs = mergeTypeDefs([RESOLVE_TO_DIRECTIVE_DEF, mergedTypeDefs]);
|
|
648
|
+
}
|
|
617
649
|
return mergedTypeDefs;
|
|
618
650
|
}
|
|
619
651
|
const handleFederationSupergraph = function({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/fusion-runtime",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.7-alpha-971df8ca5edef1a97ddf1332eb144ea01e16342e",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Runtime for GraphQL Mesh Fusion Supergraph",
|
|
6
6
|
"repository": {
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"tslib": "^2.8.1"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@graphql-hive/router-runtime": "
|
|
68
|
+
"@graphql-hive/router-runtime": "1.3.3-alpha-971df8ca5edef1a97ddf1332eb144ea01e16342e",
|
|
69
69
|
"change-case": "^5.4.4",
|
|
70
70
|
"graphql": "^16.12.0",
|
|
71
71
|
"pkgroll": "2.27.0"
|