A GraphQL schema is composed of many building blocks. These building blocks are as follows:
- Types
- Queries
- Functions
- Aliases
- Variables
- Mutations
All these blocks are essential for building a functional GraphQL API. We can divide all of these components into two main categories:
- Schemas and types
- Queries and mutations
There are many features in each category, but we will only discuss the most important ones that can help you understand GraphQL. Let's take an example of fetching a user record from an API.
Note: All the snippets we show from here on are present in the intro directory of Chapter10, GraphQL and Go.
A typical GraphQL schema looks like this:
type Query {
user: Person
}
type Person {
name: String,
address: [Address]
}
type Address {
city: String,
street: String,
postalCode: Float
}
This is a GraphQL schema with three types: one special type called...