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)
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
@merko30 Please read the docs before asking questions đ https://typegraphql.com/docs/faq.html#situations-frequently-arise-where-inputtype-and-objecttype-have-exactly-the-same-shape-how-can-i-share-the-definitions
For the record, this error also shows when you try using an enum without registering it:
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
@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.