Defining Input Types in GraphQL Schema
Input types in declared using the input keyword in GraphQL, and they are used to define the types for input arguments in a GraphQL query API. These arguments, then, define the structure of how the API request data structure would look like. Let’s take a look at the example below –
input UserInput {
username: String!
email: String!
password: String!
}
Here, UserInput is an input type that suggests that the UserInput query accepts username, email, and password only in its request data structure.
Input Types in GraphQL Schema
GraphQL is an open-source Query Language for APIs that allows us to query only the data we require, unlike the REST framework which returns the entire data as is configured in its API. With GraphQL, we can maintain a Schema that defines what data we can query from the server, and we can define a proper contractual schema like this between the client and the server. In this article, we will learn about the Union Types in GraphQL Schema, and implement our resolver for it in Node.JS.