'Dynamically generate Input based on a type in GraphQL

I am trying to implement a complex query with filter where e.g.

type Query {
  products(where: WhereInput): [Product!]!
}

type Product {
...
}

Is it possible to generate the WhereInput dynamically based on Product fields rather than typing the input fields statically? i.e. instead of having to type

type Product {
  id: ID!
  name: String!
}
input WhereInput {
  id: ID
  id_not: ID!
  id_in: [ID!]
  id_not_in: [ID!]
  name: String
  name_not: String
  ...
}

Later, the Product type might change so, we do not want to change the scalar manually "could be just renaming"

type Product {
  id: ID!
  title: String!  # replaced `name` with `title`
}
input WhereInput {
  ...
  title: String
  title_not: String
  ...
} 

Thus, having an auto-generated input based on Product fields would be so helpful.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source