Ask questionsAdding any @FieldResolver crashes build

Describe the Bug Adding the @ Field decorator to a model does nothing and adding the @ FieldResolver decorator to a Resolver crashes the build process. Either this is a bug or I have done something wrong.

Adding any @ FieldResolver decorator will cause this, even one that simply returns a preset string.

To Reproduce


export class AlbumModel {
  @Field(() => ID)
  id: string;

  title: string;

  // @Field(() => [SocialLinkModel])
  // social: SocialLinkModel[];

 // @Field(() => [SocialLinkModel])
 // social(@Root() album: AlbumEntity) {
 //   return ?? [];
 // }


export class SocialLinkModel {
  @Field(() => ID)
  id: string;

  site: string;

  url: string;

[3] In addition, doing this in place of [2] causes the same issue

 @Field(() => [SocialLinkModel])
  social(@Root() album: AlbumEntity): SocialLinkModel[] {
    return [{ id: "2", url: "foo", site: 1 }];


@Resolver((_of) => AlbumModel)
export class AlbumResolver {

  @FieldResolver(() => [SocialLinkModel])
  async social(@Root() album: AlbumEntity) {
    return ?? [];

  @Query(() => [AlbumModel])
  albums() {
    return AlbumEntity.find({ relations : ["social","social.links"] });

Expected Behavior [1]: Either the The schema should be able to build with the resolveProperty and work as expected. or [2] or [3]: The @Field should return the value in the return function.

Logs [1]

(node:76612) UnhandledPromiseRejectionWarning: Error: Unable to find type metadata for input type or object type named ''
    at /Users/me/documents/api/node_modules/type-graphql/dist/metadata/metadata-storage.js:183:27
    at Array.forEach (<anonymous>)
    at MetadataStorage.buildFieldResolverMetadata (/Users/me/documents/api/node_modules/type-graphql/dist/metadata/metadata-storage.js:167:21)
    at (/Users/me/documents/api/node_modules/type-graphql/dist/metadata/metadata-storage.js:100:14)
    at Function.generateFromMetadataSync (/Users/me/documents/api/node_modules/type-graphql/dist/schema/schema-generator.js:27:51)
    at Function.generateFromMetadata (/Users/me/documents/api/node_modules/type-graphql/dist/schema/schema-generator.js:15:29)
    at Object.buildSchema (/Users/me/documents/api/node_modules/type-graphql/dist/utils/buildSchema.js:9:61)

[2] and [3] image

Environment (please complete the following information):

  • OS: [macOS 10.15.4]
  • Node (v12.16.3)
  • Package version [^1.0.0-rc.1] and [0.18.0-beta.17]
  • TypeScript version [^3.8.3]
  • TypeORM version [^0.2.24]

Additional Context Thanks for taking the time to look at this. Love this framework, would love to figure this out so I can continue using it!


Answer questions leobar37


Github User Rank List