In this chapter, you will learn about the GraphQL schema:
graphqllibrary as a basic GraphQL execution mechanism
To get a better understanding of how GraphQL works, you can start by reading this tutorial about GraphQL basics.
If you are already familiar with the basics of GraphQL, here’s a quick overview:
The GraphQL schema is where your GraphQL types are defined.
GraphQL types are connected to each other using fields, and they form a graph.
Mutation types are special, since they act as entry point to the graph.
The GraphQL schema acts as the data provider, and it offers a set of capabilities the consumer can use.
To get data from a GraphQL schema, you need to write a GraphQL operation (a
query) that selects the data and fields you need.
In this section of the tutorial, you’ll write a simple GraphQL schema, and you’ll consume it directly, just for the learning process.
Later, you’ll replace the direct execution with a GraphQL server (based on HTTP protocol), and you’ll add developer tools that will make it super simple to query and access.
There are many ways to create a GraphQL schema - in this tutorial, you are going to use schema-first approach, and build the schema with the
@graphql-tools/schema library (take a look at the end of this chapter for more advanced/different solutions for creating your GraphQL schema).
A GraphQL schema can be written with GraphQL SDL (Schema Definition Language), which is the GraphQL language for defining your API/contract. The actual code and business-logic of each field is called a GraphQL resolvers.
So let’s get started by creating your first, very-simple, GraphQL schema.