Docblock tags
Inputs
On this page
To define a GraphQL input type, put a @gqlInput docblock directly before a:
- type alias declaration;
- interface declaration.
As with other tags, the name after the tag, if any, is the input's name in the schema, when it differs from the type's name.
/**
* Description of my input type
* @gqlInput
*/
type MyInput = {
name: string;
};"""Description of my input type"""
input MyInput {
name: String!
}/** @gqlInput */
interface MyInput {
name: string;
}input MyInput {
name: String!
}Unlike the fields of a type or an interface, every property of an input type is part of its GraphQL definition. You do not annotate each property with @gqlField.
Deprecated fields
An optional field can be marked @deprecated in the GraphQL schema with the @deprecated JSDoc tag:
import type { Int } from "gratos";
/** @gqlInput */
type MyInput = {
name: string;
/** @deprecated Don't ask for age any more */
age?: Int;
};input MyInput {
age: Int @deprecated(reason: "Don't ask for age any more")
name: String!
}Merged interfaces
TypeScript merges interfaces when you define several interfaces with the same name in the same scope. For example, Node is a built-in interface that describes DOM nodes, so a Node interface of your own is merged with the built-in one.
To avoid ambiguity, Gratos reports an error when a GraphQL input type is defined with a merged TypeScript interface. To avoid the error, define an interface with a unique name, and rename it to the name you want in your schema.