How does @noinput directive work?

In the previous post, we have seen how to mark fields as deprecated using @deprecated directive.
Now we will check how @noinput directive works.

  • When you declare a data type in the schema, Hypi automatically generates input data types that are used to implement CRUD functions.
  • Let’s say you declare an ABC data type. The auto generated data types will be ABCInput and ABCInputOpt.
  • If you declare the data type with @noinput directive, above mentioned input data types will not be generated.
  • The data type becomes immutable. This prevents objects of this type from being used in upsert and other functions.
  • You can return objects of the type from serverless functions or the api gateway.

Check this guide to learn more about GraphQL Input types.
GraphQL Input and Output types follow the Data Access Object (DAO) design pattern.

Declare below Data type in the schema.

type AbcObj @noinput {
   field: String
}

The Input data types AbcObjInput and AbcObjInputOpt will not be generated.If you try to use upsert with AbcObj data type, below error will get popped up in the GraphQL Playground.