Our Schema Module

To build a GraphQL API, you’ll need to construct a GraphQL schema, which defines its domain model and how data is retrieved. That can seem pretty overwhelming at first, so we’ll help you start by showing you where to put the schema and ease you into your first query.

We want this schema to support clients of our API accessing a list of menu items. An example query from a client might look something like this:

 {
  menuItems {
  name
  }
 }

If the user was talking to us, this would translate to “Give me the names of all of the menu items that you have.” Here’s a sample of the type of JSON they’d expect in response:

 {
 "data"​: {
 "menuItems"​: [
  {​"name"​: ​"Reuben"​},
  {​"name"​: ​"Croque Monsieur"​},
  {​"name"​: ​ ...

Get Craft GraphQL APIs in Elixir with Absinthe now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.