@@ -590,6 +590,7 @@ __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
590
590
const testSchema = buildSchema ( /* GraphQL */ `
591
591
type Query {
592
592
a: A
593
+ c: C
593
594
}
594
595
595
596
enum A {
@@ -606,11 +607,17 @@ __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
606
607
type B {
607
608
a: String
608
609
}
610
+
611
+ enum C {
612
+ Y
613
+ Z
614
+ }
609
615
` ) ;
610
616
611
617
const config = {
612
618
enumValues : {
613
619
A : 'MyA' ,
620
+ C : '../enums.js#MyC' ,
614
621
} ,
615
622
typesPrefix : 'GQL_' ,
616
623
} ;
@@ -622,9 +629,13 @@ __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
622
629
623
630
expect ( mergedOutputs ) . not . toContain ( `A: A;` ) ;
624
631
expect ( mergedOutputs ) . not . toContain ( `A: GQL_A;` ) ;
632
+ expect ( mergedOutputs ) . not . toContain ( `C: GQL_MyC;` ) ;
625
633
expect ( mergedOutputs ) . toContain ( `NotMapped: GQL_NotMapped;` ) ;
626
634
expect ( mergedOutputs ) . not . toContain ( `NotMapped: NotMapped;` ) ;
635
+ expect ( mergedOutputs ) . toContain ( `A: MyA;` ) ;
627
636
expect ( mergedOutputs ) . toContain ( `B: GQL_B;` ) ;
637
+ expect ( mergedOutputs ) . toContain ( `C: C;` ) ;
638
+ expect ( mergedOutputs ) . toContain ( `import { MyC as C } from '../enums.js';` ) ;
628
639
} ) ;
629
640
630
641
it ( 'Should allow to generate optional __resolveType' , async ( ) => {
@@ -2260,7 +2271,7 @@ export type ResolverFn<TResult, TParent, TContext, TArgs> = (
2260
2271
ProjectRoleDetail : '../entities#ProjectRole' ,
2261
2272
} ,
2262
2273
enumValues : {
2263
- ProjectRole : '../entities#ProjectRole ' ,
2274
+ ProjectRole : '../entities#AnotherProjectRole ' ,
2264
2275
} ,
2265
2276
} ;
2266
2277
@@ -2272,8 +2283,11 @@ export type ResolverFn<TResult, TParent, TContext, TArgs> = (
2272
2283
expect ( output . prepend . filter ( t => t . includes ( 'import' ) ) . length ) . toBe ( 2 ) ;
2273
2284
expect ( output . prepend . filter ( t => t . includes ( 'ProjectRole' ) ) . length ) . toBe ( 0 ) ;
2274
2285
expect ( tsContent . prepend . filter ( t => t . includes ( 'ProjectRole' ) ) . length ) . toBe ( 1 ) ;
2275
- expect ( tsContent . prepend . includes ( `import { ProjectRole } from '../entities';` ) ) . toBeTruthy ( ) ;
2276
- expect ( output . prepend . includes ( `import { ProjectRole } from '../entities';` ) ) . toBeFalsy ( ) ;
2286
+ expect ( output . content . includes ( 'AnotherProjectRole' ) ) . toBeFalsy ( ) ;
2287
+ expect (
2288
+ tsContent . prepend . includes ( `import { AnotherProjectRole as ProjectRole } from '../entities';` )
2289
+ ) . toBeTruthy ( ) ;
2290
+ expect ( output . prepend . includes ( `import { AnotherProjectRole as ProjectRole } from '../entities';` ) ) . toBeFalsy ( ) ;
2277
2291
} ) ;
2278
2292
2279
2293
it ( '#3264 - enumValues is not being applied to directive resolver' , async ( ) => {
0 commit comments