An Introduction to 

GraphQL

A Query Language for your API

Design By Contract

schema {
  query: Query
  mutation: Mutation
}

type Query {
  tasks: [Task]!
}

type Mutation {
  addTask(text: String!): [Task]!
}

type Task {
  id: ID
  text: String!
  finished: Boolean,
  assignee: User
}

type User {
  id: ID
  name: String!
}

Server

Get only what you need

query getUnfinishedTasks {
    todos(finished: false) {
        text
    }
}

Client

{
    "data": {
        "todos": [{
            "text": "Continue procrastinating",
            "text": "Drink more beer",
            "text": "Do something grand"
        }]
    }
}

GraphQL Query

JSON Response

Server

Data Sources

App

Clients

GraphQL Queries

JSON Payload

Database

Rest API

???

Clients can be simple

curl -XPOST -H "Content-Type:application/graphql" -d \
    'query { tasks }' http://localhost:3000/graphql
{
  "data": {
    "tasks": [
      {
        "text": "Eat pizza"
      }
    ]
  }
}

Servers need a runtime

Relay

Bindings in

Demo

Questions

Made with Slides.com