Skip to content

Input object can't have nested input object field #1754

@ashleyxue529

Description

@ashleyxue529

Setup

I have AInput that contains an inner BInput field that I want to setup like this:

@gqlInputObjectType()
export class AInput {
  @gqlField({
    class: "AInput",
    type: "BInput",
  })
  bInput: BInput;

  constructor(bInput: BInput) {
       this.bInput = bInput;
  }
}

@gqlInputObjectType()
export class BInput {
  @gqlField({
    class: "BInput",
    type: GraphQLID,
  })
  id: string;

  @gqlField({
    class: "BInput",
    type: GraphQLInt,
  })
  quantity: number;

  constructor(id: string, quantity: number) {
    this.id = id;
    this.quantity = quantity;
  }
}

But I can't regen the code due to this error:

field bInput references BInput which isn't a graphql object

I tried setting up BInput using @gqlObjectType instead, which seems to successfully regen, but the graphql type is incorrect as it needs to be an Input type not just a generic type, so the server just errors out.

Question

Should there be a separate @gqlInputField we can use? Or is there a setup I'm missing? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions