Tutorial
The tutorial assumes that you're familiar with ES2015 concepts like computed keys, arrow functions, and template literals.
In this tutorial, we're going to create two JavaScript classes: User
and Blog
, and five files: schema.js
, queries.js
, mutations.js
, middleware.js
, and the index.js
entry file. Then, we'll use them to compile a GraphQLSchema
and plug it into
express-graphql. The tutorial assumes that you have an empty, npm
project already initialized.
mkdir models
touch index.js schema.js queries.js mutations.js middleware.js models/User.js models/Blog.js
- Define your business-logic layer
- Define your schema
- Root queries and mutations
- Middleware
- Wire everything together
If you don't really care for tutorials and just want to see some code, you can check out some examples.