@graphql-codegen/visitor-plugin-common 6.0.0-alpha-20250219094450-c0f73ba2266dfdde71725fb9a05c6286b0515874 → 6.0.0-alpha-20250305100622-bf44cc9a5598cb0d0790bc03ee0f26743002ccd6
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.
|
@@ -86,6 +86,7 @@ class BaseResolversVisitor extends base_visitor_js_1.BaseVisitor {
|
|
|
86
86
|
clearWrapper: type => this.clearResolverTypeWrapper(type),
|
|
87
87
|
getTypeToUse: name => this.getTypeToUse(name),
|
|
88
88
|
currentType: 'ResolversTypes',
|
|
89
|
+
onNotMappedObjectType: ({ initialType }) => initialType,
|
|
89
90
|
});
|
|
90
91
|
this._resolversParentTypes = this.createResolversFields({
|
|
91
92
|
applyWrapper: type => type,
|
|
@@ -93,6 +94,17 @@ class BaseResolversVisitor extends base_visitor_js_1.BaseVisitor {
|
|
|
93
94
|
getTypeToUse: name => this.getParentTypeToUse(name),
|
|
94
95
|
currentType: 'ResolversParentTypes',
|
|
95
96
|
shouldInclude: namedType => !(0, graphql_1.isEnumType)(namedType),
|
|
97
|
+
onNotMappedObjectType: ({ typeName, initialType }) => {
|
|
98
|
+
let result = initialType;
|
|
99
|
+
const federationReferenceTypes = this._federation.printReferenceSelectionSets({
|
|
100
|
+
typeName,
|
|
101
|
+
baseFederationType: `${this.convertName('FederationTypes')}['${typeName}']`,
|
|
102
|
+
});
|
|
103
|
+
if (federationReferenceTypes) {
|
|
104
|
+
result += ` | ${federationReferenceTypes}`;
|
|
105
|
+
}
|
|
106
|
+
return result;
|
|
107
|
+
},
|
|
96
108
|
});
|
|
97
109
|
this._resolversUnionTypes = this.createResolversUnionTypes();
|
|
98
110
|
this._resolversInterfaceTypes = this.createResolversInterfaceTypes();
|
|
@@ -139,7 +151,7 @@ class BaseResolversVisitor extends base_visitor_js_1.BaseVisitor {
|
|
|
139
151
|
return `${applyNamespacedImport && this.config.namespacedImportName ? this.config.namespacedImportName + '.' : ''}${sourceType}`;
|
|
140
152
|
}
|
|
141
153
|
// Kamil: this one is heeeeavvyyyy
|
|
142
|
-
createResolversFields({ applyWrapper, clearWrapper, getTypeToUse, currentType, shouldInclude, }) {
|
|
154
|
+
createResolversFields({ applyWrapper, clearWrapper, getTypeToUse, currentType, shouldInclude, onNotMappedObjectType, }) {
|
|
143
155
|
const allSchemaTypes = this._schema.getTypeMap();
|
|
144
156
|
const typeNames = this._federation.filterTypeNames(Object.keys(allSchemaTypes));
|
|
145
157
|
// avoid checking all types recursively if we have no `mappers` defined
|
|
@@ -221,6 +233,12 @@ class BaseResolversVisitor extends base_visitor_js_1.BaseVisitor {
|
|
|
221
233
|
internalType = replacePlaceholder(this.config.mappers[typeName].type, internalType);
|
|
222
234
|
}
|
|
223
235
|
}
|
|
236
|
+
else {
|
|
237
|
+
internalType = onNotMappedObjectType({
|
|
238
|
+
typeName,
|
|
239
|
+
initialType: internalType,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
224
242
|
prev[typeName] = applyWrapper(internalType);
|
|
225
243
|
}
|
|
226
244
|
}
|
|
@@ -82,6 +82,7 @@ export class BaseResolversVisitor extends BaseVisitor {
|
|
|
82
82
|
clearWrapper: type => this.clearResolverTypeWrapper(type),
|
|
83
83
|
getTypeToUse: name => this.getTypeToUse(name),
|
|
84
84
|
currentType: 'ResolversTypes',
|
|
85
|
+
onNotMappedObjectType: ({ initialType }) => initialType,
|
|
85
86
|
});
|
|
86
87
|
this._resolversParentTypes = this.createResolversFields({
|
|
87
88
|
applyWrapper: type => type,
|
|
@@ -89,6 +90,17 @@ export class BaseResolversVisitor extends BaseVisitor {
|
|
|
89
90
|
getTypeToUse: name => this.getParentTypeToUse(name),
|
|
90
91
|
currentType: 'ResolversParentTypes',
|
|
91
92
|
shouldInclude: namedType => !isEnumType(namedType),
|
|
93
|
+
onNotMappedObjectType: ({ typeName, initialType }) => {
|
|
94
|
+
let result = initialType;
|
|
95
|
+
const federationReferenceTypes = this._federation.printReferenceSelectionSets({
|
|
96
|
+
typeName,
|
|
97
|
+
baseFederationType: `${this.convertName('FederationTypes')}['${typeName}']`,
|
|
98
|
+
});
|
|
99
|
+
if (federationReferenceTypes) {
|
|
100
|
+
result += ` | ${federationReferenceTypes}`;
|
|
101
|
+
}
|
|
102
|
+
return result;
|
|
103
|
+
},
|
|
92
104
|
});
|
|
93
105
|
this._resolversUnionTypes = this.createResolversUnionTypes();
|
|
94
106
|
this._resolversInterfaceTypes = this.createResolversInterfaceTypes();
|
|
@@ -135,7 +147,7 @@ export class BaseResolversVisitor extends BaseVisitor {
|
|
|
135
147
|
return `${applyNamespacedImport && this.config.namespacedImportName ? this.config.namespacedImportName + '.' : ''}${sourceType}`;
|
|
136
148
|
}
|
|
137
149
|
// Kamil: this one is heeeeavvyyyy
|
|
138
|
-
createResolversFields({ applyWrapper, clearWrapper, getTypeToUse, currentType, shouldInclude, }) {
|
|
150
|
+
createResolversFields({ applyWrapper, clearWrapper, getTypeToUse, currentType, shouldInclude, onNotMappedObjectType, }) {
|
|
139
151
|
const allSchemaTypes = this._schema.getTypeMap();
|
|
140
152
|
const typeNames = this._federation.filterTypeNames(Object.keys(allSchemaTypes));
|
|
141
153
|
// avoid checking all types recursively if we have no `mappers` defined
|
|
@@ -217,6 +229,12 @@ export class BaseResolversVisitor extends BaseVisitor {
|
|
|
217
229
|
internalType = replacePlaceholder(this.config.mappers[typeName].type, internalType);
|
|
218
230
|
}
|
|
219
231
|
}
|
|
232
|
+
else {
|
|
233
|
+
internalType = onNotMappedObjectType({
|
|
234
|
+
typeName,
|
|
235
|
+
initialType: internalType,
|
|
236
|
+
});
|
|
237
|
+
}
|
|
220
238
|
prev[typeName] = applyWrapper(internalType);
|
|
221
239
|
}
|
|
222
240
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/visitor-plugin-common",
|
|
3
|
-
"version": "6.0.0-alpha-
|
|
3
|
+
"version": "6.0.0-alpha-20250305100622-bf44cc9a5598cb0d0790bc03ee0f26743002ccd6",
|
|
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": "6.0.0-alpha-
|
|
9
|
+
"@graphql-codegen/plugin-helpers": "6.0.0-alpha-20250305100622-bf44cc9a5598cb0d0790bc03ee0f26743002ccd6",
|
|
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",
|
|
@@ -665,12 +665,16 @@ export declare class BaseResolversVisitor<TRawConfig extends RawResolversConfig
|
|
|
665
665
|
getResolverTypeWrapperSignature(): string;
|
|
666
666
|
protected shouldMapType(type: GraphQLNamedType, duringCheck?: string[]): boolean;
|
|
667
667
|
convertName(node: ASTNode | string, options?: BaseVisitorConvertOptions & ConvertOptions, applyNamespacedImport?: boolean): string;
|
|
668
|
-
protected createResolversFields({ applyWrapper, clearWrapper, getTypeToUse, currentType, shouldInclude, }: {
|
|
668
|
+
protected createResolversFields({ applyWrapper, clearWrapper, getTypeToUse, currentType, shouldInclude, onNotMappedObjectType, }: {
|
|
669
669
|
applyWrapper: (str: string) => string;
|
|
670
670
|
clearWrapper: (str: string) => string;
|
|
671
671
|
getTypeToUse: (str: string) => string;
|
|
672
672
|
currentType: 'ResolversTypes' | 'ResolversParentTypes';
|
|
673
673
|
shouldInclude?: (type: GraphQLNamedType) => boolean;
|
|
674
|
+
onNotMappedObjectType: (params: {
|
|
675
|
+
initialType: string;
|
|
676
|
+
typeName: string;
|
|
677
|
+
}) => string;
|
|
674
678
|
}): ResolverTypes;
|
|
675
679
|
protected replaceFieldsInType(typeName: string, relevantFields: ReturnType<typeof this.getRelevantFieldsToOmit>): string;
|
|
676
680
|
protected applyMaybe(str: string): string;
|
|
@@ -665,12 +665,16 @@ export declare class BaseResolversVisitor<TRawConfig extends RawResolversConfig
|
|
|
665
665
|
getResolverTypeWrapperSignature(): string;
|
|
666
666
|
protected shouldMapType(type: GraphQLNamedType, duringCheck?: string[]): boolean;
|
|
667
667
|
convertName(node: ASTNode | string, options?: BaseVisitorConvertOptions & ConvertOptions, applyNamespacedImport?: boolean): string;
|
|
668
|
-
protected createResolversFields({ applyWrapper, clearWrapper, getTypeToUse, currentType, shouldInclude, }: {
|
|
668
|
+
protected createResolversFields({ applyWrapper, clearWrapper, getTypeToUse, currentType, shouldInclude, onNotMappedObjectType, }: {
|
|
669
669
|
applyWrapper: (str: string) => string;
|
|
670
670
|
clearWrapper: (str: string) => string;
|
|
671
671
|
getTypeToUse: (str: string) => string;
|
|
672
672
|
currentType: 'ResolversTypes' | 'ResolversParentTypes';
|
|
673
673
|
shouldInclude?: (type: GraphQLNamedType) => boolean;
|
|
674
|
+
onNotMappedObjectType: (params: {
|
|
675
|
+
initialType: string;
|
|
676
|
+
typeName: string;
|
|
677
|
+
}) => string;
|
|
674
678
|
}): ResolverTypes;
|
|
675
679
|
protected replaceFieldsInType(typeName: string, relevantFields: ReturnType<typeof this.getRelevantFieldsToOmit>): string;
|
|
676
680
|
protected applyMaybe(str: string): string;
|