diff --git a/packages/plugins/other/visitor-plugin-common/src/base-resolvers-visitor.ts b/packages/plugins/other/visitor-plugin-common/src/base-resolvers-visitor.ts index 19351915e15..a5132c3a54a 100644 --- a/packages/plugins/other/visitor-plugin-common/src/base-resolvers-visitor.ts +++ b/packages/plugins/other/visitor-plugin-common/src/base-resolvers-visitor.ts @@ -873,13 +873,9 @@ export class BaseResolversVisitor< this.markMapperAsUsed(typeName); prev[typeName] = applyWrapper(this.config.mappers[typeName].type); } else if (isEnumType(schemaType) && this.config.enumValues[typeName]) { - const isExternalFile = !!this.config.enumValues[typeName].sourceFile; - prev[typeName] = isExternalFile - ? this.convertName(this.config.enumValues[typeName].typeIdentifier, { - useTypesPrefix: false, - useTypesSuffix: false, - }) - : this.config.enumValues[typeName].sourceIdentifier; + prev[typeName] = + this.config.enumValues[typeName].sourceIdentifier || + this.convertName(this.config.enumValues[typeName].typeIdentifier); } else if (hasDefaultMapper && !hasPlaceholder(this.config.defaultMapper.type)) { prev[typeName] = applyWrapper(this.config.defaultMapper.type); } else if (isScalar) { diff --git a/packages/plugins/typescript/resolvers/tests/ts-resolvers.spec.ts b/packages/plugins/typescript/resolvers/tests/ts-resolvers.spec.ts index a1d13fe829e..595a548d0f3 100644 --- a/packages/plugins/typescript/resolvers/tests/ts-resolvers.spec.ts +++ b/packages/plugins/typescript/resolvers/tests/ts-resolvers.spec.ts @@ -590,7 +590,6 @@ __isTypeOf?: IsTypeOfResolverFn; const testSchema = buildSchema(/* GraphQL */ ` type Query { a: A - c: C } enum A { @@ -607,17 +606,11 @@ __isTypeOf?: IsTypeOfResolverFn; type B { a: String } - - enum C { - Y - Z - } `); const config = { enumValues: { A: 'MyA', - C: '../enums.js#MyC', }, typesPrefix: 'GQL_', }; @@ -629,13 +622,9 @@ __isTypeOf?: IsTypeOfResolverFn; expect(mergedOutputs).not.toContain(`A: A;`); expect(mergedOutputs).not.toContain(`A: GQL_A;`); - expect(mergedOutputs).not.toContain(`C: GQL_MyC;`); expect(mergedOutputs).toContain(`NotMapped: GQL_NotMapped;`); expect(mergedOutputs).not.toContain(`NotMapped: NotMapped;`); - expect(mergedOutputs).toContain(`A: MyA;`); expect(mergedOutputs).toContain(`B: GQL_B;`); - expect(mergedOutputs).toContain(`C: C;`); - expect(mergedOutputs).toContain(`import { MyC as C } from '../enums.js';`); }); it('Should allow to generate optional __resolveType', async () => { @@ -2271,7 +2260,7 @@ export type ResolverFn = ( ProjectRoleDetail: '../entities#ProjectRole', }, enumValues: { - ProjectRole: '../entities#AnotherProjectRole', + ProjectRole: '../entities#ProjectRole', }, }; @@ -2283,11 +2272,8 @@ export type ResolverFn = ( expect(output.prepend.filter(t => t.includes('import')).length).toBe(2); expect(output.prepend.filter(t => t.includes('ProjectRole')).length).toBe(0); expect(tsContent.prepend.filter(t => t.includes('ProjectRole')).length).toBe(1); - expect(output.content.includes('AnotherProjectRole')).toBeFalsy(); - expect( - tsContent.prepend.includes(`import { AnotherProjectRole as ProjectRole } from '../entities';`) - ).toBeTruthy(); - expect(output.prepend.includes(`import { AnotherProjectRole as ProjectRole } from '../entities';`)).toBeFalsy(); + expect(tsContent.prepend.includes(`import { ProjectRole } from '../entities';`)).toBeTruthy(); + expect(output.prepend.includes(`import { ProjectRole } from '../entities';`)).toBeFalsy(); }); it('#3264 - enumValues is not being applied to directive resolver', async () => {