8 [Absinthe](http://absinthe-graphql.org/) allows you to write GraphQL servers in Elixir.
15 - `Schema` - The root. Defines what queries you can do, and what types they return.
16 - `Resolver` - Functions that return data.
17 - `Type` - A type definition describing the shape of the data you'll return.
24 defmodule Blog.Web.Router do
27 forward "/", Absinthe.Plug,
33 Absinthe is a Plug, and you pass it one **Schema**.
35 See: [Our first query](http://absinthe-graphql.org/tutorial/our-first-query/)
45 defmodule Blog.Schema do
47 import_types Blog.Schema.Types
50 @desc "Get a list of blog posts"
51 field :posts, list_of(:post) do
52 resolve &Blog.PostResolver.all/2
57 {: data-line="5,6,7,8,9,10"}
59 This schema will account for `{ posts { ··· } }`. It returns a **Type** of `:post`, and delegates to a **Resolver**.
63 #### web/resolvers/post_resolver.ex
66 defmodule Blog.PostResolver do
67 def all(_args, _info) do
68 {:ok, Blog.Repo.all(Blog.Post)}
74 This is the function that the schema delegated the `posts` query to.
78 #### web/schema/types.ex
81 defmodule Blog.Schema.Types do
82 use Absinthe.Schema.Notation
92 {: data-line="4,5,6,7,8,9"}
94 This defines a type `:post`, which is used by the resolver.
103 { user(id: "1") { ··· } }
110 field :user, type: :user do
111 arg :id, non_null(:id)
112 resolve &Blog.UserResolver.find/2
121 def find(%{id: id} = args, _info) do
127 See: [Query arguments](http://absinthe-graphql.org/tutorial/query-arguments/)
135 mutation CreatePost {
136 post(title: "Hello") { id }
145 @desc "Create a post"
146 field :post, type: :post do
147 arg :title, non_null(:string)
148 resolve &Blog.PostResolver.create/2
154 See: [Mutations](http://absinthe-graphql.org/tutorial/mutations/)
158 - [Absinthe website](http://absinthe-graphql.org/) _(absinthe-graphql.org)_
159 - [GraphQL cheatsheet](./graphql) _(devhints.io)_