Type-graphql: Cannot determine GraphQL input type for

Created on 8 Jul 2019  路  10Comments  路  Source: MichalLytek/type-graphql

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[];

}
Invalid Question

Most helpful comment

_For future readers_

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

See docs for: inputType

All 10 comments

Please paste more code, or maybe even better - create a repository with a minimal reproducible code example.

Closing for a housekeeping purposes as there's no response from the issue author 馃敀

_For future readers_

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

See docs for: inputType

Could you help me with this:

@InputType()
class OrderInputType implements Partial<Order> {
  @Field(type => [Item])
  items: Item[];

  @Field(() => Int)
  totalPrice: number;
}

I get Error: Cannot determine GraphQL input type for items

@merko30
Item also has to be an @InputType

How can I declare ObjectType as InputType at the same time ?

For example, I have an order model, it has many products. OrderInput needs to have many products, but it has to be InputType, I tried ProductType implements Product, but it doesn't work.

@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

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

@MichalLytek you should edit your link, looks like typegraphql.ml sends on a "scam" website

@MichalLytek you should edit your link, looks like typegraphql.ml sends on a "scam" website

Yep! It's sends to "scam" website

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robertchung97 picture robertchung97  路  3Comments

Janushan picture Janushan  路  3Comments

tafelito picture tafelito  路  3Comments

oliversalzburg picture oliversalzburg  路  3Comments

Tybot204 picture Tybot204  路  3Comments