type-graphql: Cannot determine GraphQL input type for

throw new Error(Cannot determine GraphQL input type for ${typeOwnerName}`); ^

Error: Cannot determine GraphQL input type for company` having this error my resolver

@Resolver()
export class CategoriesResolver {
  @Query(() => CategoriesData)
  async get_category_by_id(@Arg('company', type => CompanyData) company: CompanyData, @Arg('id') id: String): Promise<any> {
    let cat = new GetCategoryByIdLib()
    return cat.getCategoryById(company, id)
  }
}

My Data Fields

@ObjectType('CompanyData')
export class CompanyData {

    @Field(type => ID)
    _id : String

    @Field(type => String, {nullable: true})
    name: String;

    @Field(type => String, {nullable: true})
    email: String;

    @Field(type => String, {nullable: true})
    api_key: String;

    @Field(type => DocumentsData, {nullable: true})
    document: DocumentsData;

    @Field(type => [String], {nullable: true})
    phones: String[];

    @Field(type => AddressData, {nullable: true})
    address: AddressData;

    @Field(type => ImagesData, {nullable: true})
    avatar: ImagesData;

    @Field(type => [CustomerData], {nullable: true})
    customers: CustomerData[];

}

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 3
  • Comments: 16 (4 by maintainers)

Most upvoted comments

For future readers

This may have been due to using an @ObjectType() CompanyData as an @InputType() in the resolver.

See docs for: inputType

@merko30 Item also has to be an @InputType

For the record, this error also shows when you try using an enum without registering it:

registerEnumType(MyEnum, {
  name: 'MyEnum',
  description: 'MyEnum description',
});

This error is also triggered when providing ObjectType as argument for a resolver function.

@Arg("argument") argumentInput: Argument

instead of

@Arg("argument") argumentInput: ArgumentInput

where Argument is @ObjectType and ArgumentInput is @InputType

use GraphQLJSONObject if you want to pass an object as an input type property

 @Field(() => GraphQLJSONObject, { nullable: true })
 employee: UserObject;

@aurinxki that’s exactly what I ended up doing. Thanks for your response! I do understand that object types can hold “weird” data and that’s probably why it can’t be used in this way, but I do wish it worked that way or was better documented that it can’t be used that way.