GraphQL

A query language for your API

...the problem

  • Data on the wire
  • Client complexity
  • Strict REST and ad hoc endpoints
  • Documentation
  • Designed back to front

GraphQL

GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools.

  • Data on the wire
  • Client complexity

Documentation

Strict REST and

ad hoc endpoints

Front to back

Start with frontend need and work back to technology

/users

/users/gurra

/items

Data

Loader

 

Cache

Cache

/graphql

GraphiQL

auth

compression

persisted queries

schema

...gives clients the power to ask for exactly what they need and nothing more

Query Language

Query Language


query { 
  user {
    id,
    name
  }
}


user: [{
  id: "3",
  name: "kits"
}]

GraphQL is a query language for APIs

Thin wrapper

Single HTTP endpoint

Authorization

per field, not per url

GraphQL provides a complete and understandable description of the data in your API

Self documenting

...and enables powerful developer tools

GraphiQL

Cache

Frontend

  • Disc cache to serve offline apps

Backend

  • Per field / fragment / resolver

Batch

  • https://github.com/facebook/dataloader

(DataLoader)

Best Practices

Edges - Nodes - Connections

  • https://dev-blog.apollodata.com/explaining-graphql-connections-c48b7c3d6976#.r6kujamav

Persisted queries

  • https://dev-blog.apollodata.com/persisted-graphql-queries-with-apollo-client-119fd7e6bba5#.q6b5cm4et
  • https://dev-blog.apollodata.com/5-benefits-of-static-graphql-queries-b7fa90b0b69a#.1dwfsgv8a

JSON => GZIP

Accept-Encoding: gzip

(Compression)

...makes it easier to evolve APIs over time

(API Versions?)

@deprecated

Design the product v2.0, not the api v2.0

New Stuff

Subscriptions

  • https://dev-blog.apollodata.com/new-release-of-graphql-subscriptions-for-javascript-f11be19e6569#.23wsk4r7p

GraphQL

By Gustav Jorlöv

GraphQL

  • 220