@graphql-codegen/visitor-plugin-common 5.6.1-rc-20250118081149-55f7ee4aab7d41c285ef1a76bac8bf5b4d20a327 → 6.0.0-alpha-20250118081501-dd2b0bdaa05321a511f89cfeee5bf398fc77b86b
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.
|
@@ -440,6 +440,23 @@ class BaseResolversVisitor extends base_visitor_js_1.BaseVisitor {
|
|
|
440
440
|
.map(([typeName, value]) => (0, utils_js_1.indent)(`${typeName}: ${value}${this.getPunctuation(declarationKind)}`))
|
|
441
441
|
.join('\n')).string;
|
|
442
442
|
}
|
|
443
|
+
buildFederationTypes() {
|
|
444
|
+
const federationMeta = this._federation.getMeta();
|
|
445
|
+
if (Object.keys(federationMeta).length === 0) {
|
|
446
|
+
return '';
|
|
447
|
+
}
|
|
448
|
+
const declarationKind = 'type';
|
|
449
|
+
return new utils_js_1.DeclarationBlock(this._declarationBlockConfig)
|
|
450
|
+
.export()
|
|
451
|
+
.asKind(declarationKind)
|
|
452
|
+
.withName(this.convertName('FederationTypes'))
|
|
453
|
+
.withComment('Mapping of federation types')
|
|
454
|
+
.withBlock(Object.keys(federationMeta)
|
|
455
|
+
.map(typeName => {
|
|
456
|
+
return (0, utils_js_1.indent)(`${typeName}: ${this.convertName(typeName)}${this.getPunctuation(declarationKind)}`);
|
|
457
|
+
})
|
|
458
|
+
.join('\n')).string;
|
|
459
|
+
}
|
|
443
460
|
get schema() {
|
|
444
461
|
return this._schema;
|
|
445
462
|
}
|
|
@@ -646,6 +663,7 @@ class BaseResolversVisitor extends base_visitor_js_1.BaseVisitor {
|
|
|
646
663
|
fieldNode: original,
|
|
647
664
|
parentType,
|
|
648
665
|
parentTypeSignature: this.getParentTypeForSignature(node),
|
|
666
|
+
federationTypeSignature: 'FederationType',
|
|
649
667
|
});
|
|
650
668
|
const mappedTypeKey = isSubscriptionType ? `${mappedType}, "${node.name}"` : mappedType;
|
|
651
669
|
const directiveMappings = node.directives
|
|
@@ -727,10 +745,18 @@ class BaseResolversVisitor extends base_visitor_js_1.BaseVisitor {
|
|
|
727
745
|
if (!rootType) {
|
|
728
746
|
fieldsContent.push((0, utils_js_1.indent)(`${this.config.internalResolversPrefix}isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>${this.getPunctuation(declarationKind)}`));
|
|
729
747
|
}
|
|
748
|
+
const genericTypes = [
|
|
749
|
+
`ContextType = ${this.config.contextType.type}`,
|
|
750
|
+
this.transformParentGenericType(parentType),
|
|
751
|
+
];
|
|
752
|
+
if (this._federation.getMeta()[typeName]) {
|
|
753
|
+
const typeRef = `${this.convertName('FederationTypes')}['${typeName}']`;
|
|
754
|
+
genericTypes.push(`FederationType extends ${typeRef} = ${typeRef}`);
|
|
755
|
+
}
|
|
730
756
|
const block = new utils_js_1.DeclarationBlock(this._declarationBlockConfig)
|
|
731
757
|
.export()
|
|
732
758
|
.asKind(declarationKind)
|
|
733
|
-
.withName(name,
|
|
759
|
+
.withName(name, `<${genericTypes.join(', ')}>`)
|
|
734
760
|
.withBlock(fieldsContent.join('\n'));
|
|
735
761
|
this._collectedResolvers[node.name] = {
|
|
736
762
|
typename: name + '<ContextType>',
|
|
@@ -436,6 +436,23 @@ export class BaseResolversVisitor extends BaseVisitor {
|
|
|
436
436
|
.map(([typeName, value]) => indent(`${typeName}: ${value}${this.getPunctuation(declarationKind)}`))
|
|
437
437
|
.join('\n')).string;
|
|
438
438
|
}
|
|
439
|
+
buildFederationTypes() {
|
|
440
|
+
const federationMeta = this._federation.getMeta();
|
|
441
|
+
if (Object.keys(federationMeta).length === 0) {
|
|
442
|
+
return '';
|
|
443
|
+
}
|
|
444
|
+
const declarationKind = 'type';
|
|
445
|
+
return new DeclarationBlock(this._declarationBlockConfig)
|
|
446
|
+
.export()
|
|
447
|
+
.asKind(declarationKind)
|
|
448
|
+
.withName(this.convertName('FederationTypes'))
|
|
449
|
+
.withComment('Mapping of federation types')
|
|
450
|
+
.withBlock(Object.keys(federationMeta)
|
|
451
|
+
.map(typeName => {
|
|
452
|
+
return indent(`${typeName}: ${this.convertName(typeName)}${this.getPunctuation(declarationKind)}`);
|
|
453
|
+
})
|
|
454
|
+
.join('\n')).string;
|
|
455
|
+
}
|
|
439
456
|
get schema() {
|
|
440
457
|
return this._schema;
|
|
441
458
|
}
|
|
@@ -642,6 +659,7 @@ export class BaseResolversVisitor extends BaseVisitor {
|
|
|
642
659
|
fieldNode: original,
|
|
643
660
|
parentType,
|
|
644
661
|
parentTypeSignature: this.getParentTypeForSignature(node),
|
|
662
|
+
federationTypeSignature: 'FederationType',
|
|
645
663
|
});
|
|
646
664
|
const mappedTypeKey = isSubscriptionType ? `${mappedType}, "${node.name}"` : mappedType;
|
|
647
665
|
const directiveMappings = node.directives
|
|
@@ -723,10 +741,18 @@ export class BaseResolversVisitor extends BaseVisitor {
|
|
|
723
741
|
if (!rootType) {
|
|
724
742
|
fieldsContent.push(indent(`${this.config.internalResolversPrefix}isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>${this.getPunctuation(declarationKind)}`));
|
|
725
743
|
}
|
|
744
|
+
const genericTypes = [
|
|
745
|
+
`ContextType = ${this.config.contextType.type}`,
|
|
746
|
+
this.transformParentGenericType(parentType),
|
|
747
|
+
];
|
|
748
|
+
if (this._federation.getMeta()[typeName]) {
|
|
749
|
+
const typeRef = `${this.convertName('FederationTypes')}['${typeName}']`;
|
|
750
|
+
genericTypes.push(`FederationType extends ${typeRef} = ${typeRef}`);
|
|
751
|
+
}
|
|
726
752
|
const block = new DeclarationBlock(this._declarationBlockConfig)
|
|
727
753
|
.export()
|
|
728
754
|
.asKind(declarationKind)
|
|
729
|
-
.withName(name,
|
|
755
|
+
.withName(name, `<${genericTypes.join(', ')}>`)
|
|
730
756
|
.withBlock(fieldsContent.join('\n'));
|
|
731
757
|
this._collectedResolvers[node.name] = {
|
|
732
758
|
typename: name + '<ContextType>',
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/visitor-plugin-common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-alpha-20250118081501-dd2b0bdaa05321a511f89cfeee5bf398fc77b86b",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@graphql-tools/optimize": "^2.0.0",
|
|
9
|
-
"@graphql-codegen/plugin-helpers": "
|
|
9
|
+
"@graphql-codegen/plugin-helpers": "6.0.0-alpha-20250118081501-dd2b0bdaa05321a511f89cfeee5bf398fc77b86b",
|
|
10
10
|
"@graphql-tools/relay-operation-optimizer": "^7.0.0",
|
|
11
11
|
"@graphql-tools/utils": "^10.0.0",
|
|
12
12
|
"auto-bind": "~4.0.0",
|
|
@@ -693,6 +693,7 @@ export declare class BaseResolversVisitor<TRawConfig extends RawResolversConfig
|
|
|
693
693
|
buildResolversParentTypes(): string;
|
|
694
694
|
buildResolversUnionTypes(): string;
|
|
695
695
|
buildResolversInterfaceTypes(): string;
|
|
696
|
+
buildFederationTypes(): string;
|
|
696
697
|
get schema(): GraphQLSchema;
|
|
697
698
|
get defaultMapperType(): string;
|
|
698
699
|
get unusedMappers(): string[];
|
|
@@ -693,6 +693,7 @@ export declare class BaseResolversVisitor<TRawConfig extends RawResolversConfig
|
|
|
693
693
|
buildResolversParentTypes(): string;
|
|
694
694
|
buildResolversUnionTypes(): string;
|
|
695
695
|
buildResolversInterfaceTypes(): string;
|
|
696
|
+
buildFederationTypes(): string;
|
|
696
697
|
get schema(): GraphQLSchema;
|
|
697
698
|
get defaultMapperType(): string;
|
|
698
699
|
get unusedMappers(): string[];
|