@@ -26,6 +26,7 @@ import {
2626 Arg ,
2727 Authorized ,
2828 Field ,
29+ FieldResolver ,
2930 InputType ,
3031 InterfaceType ,
3132 Mutation ,
@@ -107,6 +108,15 @@ describe("typeDefs and resolvers", () => {
107108 sampleType3StringField ! : string ;
108109 }
109110
111+ @ObjectType ( "SampleType__4" )
112+ class SampleType4 {
113+ @Field ( )
114+ sampleInterfaceStringField ! : string ;
115+
116+ @Field ( )
117+ sampleType4StringField ! : string ;
118+ }
119+
110120 @InputType ( )
111121 class SampleInput {
112122 @Field ( )
@@ -241,8 +251,26 @@ describe("typeDefs and resolvers", () => {
241251 }
242252
243253 pubSub = createPubSub ( ) ;
254+
255+ @Service ( )
256+ @Resolver ( ( ) => SampleType4 )
257+ class SampleObjectTypeWithDoubleUnderscoreInNameResolver {
258+ @FieldResolver ( ( ) => String )
259+ sampleResolvedField ( ) : string {
260+ return "sampleResolvedField" ;
261+ }
262+
263+ @Query ( ( ) => SampleType4 )
264+ async sampleQueryOnObjectTypeWithDoubleUnderScore ( ) : Promise < SampleType4 > {
265+ const type4 = new SampleType4 ( ) ;
266+ type4 . sampleInterfaceStringField = "sampleInterfaceStringField" ;
267+ type4 . sampleType4StringField = "sampleType4StringField" ;
268+ return type4 ;
269+ }
270+ }
271+
244272 ( { typeDefs, resolvers } = await buildTypeDefsAndResolvers ( {
245- resolvers : [ SampleResolver ] ,
273+ resolvers : [ SampleResolver , SampleObjectTypeWithDoubleUnderscoreInNameResolver ] ,
246274 authChecker : ( ) => false ,
247275 pubSub,
248276 container : Container ,
@@ -286,6 +314,10 @@ describe("typeDefs and resolvers", () => {
286314 const sampleType2 = schemaIntrospection . types . find (
287315 it => it . name === "SampleType2" ,
288316 ) as IntrospectionObjectType ;
317+ const sampleType4 = schemaIntrospection . types . find (
318+ it => it . name === "SampleType__4" ,
319+ ) as IntrospectionObjectType ;
320+
289321 const sampleType1StringField = sampleType1 . fields . find (
290322 it => it . name === "sampleType1StringField" ,
291323 ) ! ;
@@ -299,6 +331,7 @@ describe("typeDefs and resolvers", () => {
299331 expect ( sampleType1 . interfaces ) . toHaveLength ( 1 ) ;
300332 expect ( sampleType1 . interfaces [ 0 ] . name ) . toBe ( "SampleInterface" ) ;
301333 expect ( sampleType2StringField . deprecationReason ) . toBe ( "sampleType2StringFieldDeprecation" ) ;
334+ expect ( sampleType4 . fields ) . toHaveLength ( 3 ) ;
302335 } ) ;
303336
304337 it ( "should generate input type" , async ( ) => {
@@ -356,7 +389,7 @@ describe("typeDefs and resolvers", () => {
356389 it => it . name === schemaIntrospection . queryType . name ,
357390 ) as IntrospectionObjectType ;
358391
359- expect ( queryType . fields ) . toHaveLength ( 8 ) ;
392+ expect ( queryType . fields ) . toHaveLength ( 9 ) ;
360393 } ) ;
361394
362395 it ( "should generate mutations" , async ( ) => {
@@ -574,6 +607,26 @@ describe("typeDefs and resolvers", () => {
574607 expect ( enumValue ) . toBe ( "OptionTwoString" ) ;
575608 } ) ;
576609
610+ it ( "should properly execute field resolver for object type with two underscores NOT in the beginning" , async ( ) => {
611+ const document = gql `
612+ query {
613+ sampleQueryOnObjectTypeWithDoubleUnderScore {
614+ sampleResolvedField
615+ sampleInterfaceStringField
616+ sampleType4StringField
617+ }
618+ }
619+ ` ;
620+
621+ const { data } = await execute ( { schema, document } ) ;
622+
623+ expect ( data ! . sampleQueryOnObjectTypeWithDoubleUnderScore ) . toEqual ( {
624+ sampleResolvedField : "sampleResolvedField" ,
625+ sampleInterfaceStringField : "sampleInterfaceStringField" ,
626+ sampleType4StringField : "sampleType4StringField" ,
627+ } ) ;
628+ } ) ;
629+
577630 it ( "should properly run subscriptions" , async ( ) => {
578631 const document = gql `
579632 subscription {
0 commit comments