Rest in Peace

By Kevin Greene

Why did REST

have to die?

Facebook has all of our data

Hovering over a heart

  • /pages/fmg/posts
  • /posts/fmg-1/reactions/
  • /posts/fmg-1/reactions/hearts/users
  • /users/123

Enter

GraphQL Basics

  • Describe the structure of what you want
  • Include query parameters in the structure
  • Hit a single magic URL
  • Get back exactly the data you need

Everything on Facebook

(but with GraphQL)

  • /

There's no meme

This would be very easy to hold

What actually is GraphQL?

Server Side

type User {
  name: String!
  memberOf: [Meetup]!
}


type Meetup {
  name: String!
}

Official GraphQL Syntax

Types::ProfileType = GraphQL::ObjectType.define do
  name "Profile"
  field :id, !types.ID
  field :name, !types.String
  field :avatar, Types::PhotoType
end

Programming Language Specific Syntax

npm install -g postgraphile
postgraphile

Just a DB!

Querying

(GraphiQL)

Client Side

Normal Requests

You get just as much

built-in support as REST

Relay

GraphQL can also offer

  • Mutations
  • Subscriptions
  • Happy mobile devs

Should you use it?

If these fit

  • Different interfaces / views
  • Type systems are cool
  • You want to have fun
  • You are fine still providing a REST interface

Rest isn't quite dead

Final Thoughts

  • I'm far from an expert
  • GraphQL is going to be big
  • Use it for SPAs / mobile
  • REST is from a simpler time
  • Public APIs still need to be REST

Grab me for questions

Here's Jason Swett!

GraphQL

By Kevin Greene

GraphQL

  • 69