File tree Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 66- ** Breaking Change** : ` AuthChecker ` type is now "function or class" - update to ` AuthCheckerFn ` if the function form is needed in the code
77- support class-based auth checker, which allows for dependency injection
88- allow defining directives for interface types and theirs fields, with inheritance for object types fields (#744 )
9+ ### Fixes
10+ - allow defining extension on field resolver level for fields also defined as a property of the class (#776 )
911### Others
1012- ** Breaking Change** : update ` graphql-js ` peer dependency to ` ^15.4.0 `
1113
Original file line number Diff line number Diff line change @@ -343,6 +343,7 @@ export abstract class SchemaGenerator {
343343 extensions : {
344344 complexity : field . complexity ,
345345 ...field . extensions ,
346+ ...fieldResolverMetadata ?. extensions ,
346347 } ,
347348 } ;
348349 return fieldsMap ;
Original file line number Diff line number Diff line change @@ -321,5 +321,44 @@ describe("Extensions", () => {
321321 expect ( childObjectTypeParentField . extensions ) . toEqual ( { parentField : true } ) ;
322322 } ) ;
323323 } ) ;
324+
325+ describe ( "Fields with field resolvers" , ( ) => {
326+ beforeAll ( async ( ) => {
327+ getMetadataStorage ( ) . clear ( ) ;
328+
329+ @ObjectType ( )
330+ class Child {
331+ @Field ( )
332+ @Extensions ( { childField : true } )
333+ childField ! : string ;
334+ }
335+ @Resolver ( of => Child )
336+ class ChildResolver {
337+ @Query ( )
338+ sampleQuery ( ) : Child {
339+ return { } as Child ;
340+ }
341+
342+ @Extensions ( { childFieldResolver : true } )
343+ @FieldResolver ( )
344+ childField ( ) : string {
345+ return "childField" ;
346+ }
347+ }
348+
349+ schema = await buildSchema ( {
350+ resolvers : [ ChildResolver ] ,
351+ } ) ;
352+ } ) ;
353+
354+ it ( "should merge field level with field resolver level extensions" , ( ) => {
355+ const childObjectType = schema . getType ( "Child" ) as GraphQLObjectType ;
356+
357+ expect ( childObjectType . getFields ( ) . childField . extensions ) . toEqual ( {
358+ childField : true ,
359+ childFieldResolver : true ,
360+ } ) ;
361+ } ) ;
362+ } ) ;
324363 } ) ;
325364} ) ;
You can’t perform that action at this time.
0 commit comments