GraphQL 101: What it is and why you do want it

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers. →

GraphQL 101: What it is and why you do want it

An introductory talk on GraphQL and the benefits it brings, as presented on Amsterdam JavaScript Lab HackJam Meetup.

Bojan Tomić

June 27, 2017

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

9 slides
  1. What? o Data  description  +  query  language o Server-­side  runtime

     for  executing  queries o Type system o Storage  /  language  independent  (think  REST) o Open  source  spec  (tnx Facebook!) (think  WSDL/SOAP) o Unrelated  to  graph  DBs  and  their  query  languages (Cypher,  Gremlin  etc)
  2. Why? Describe  data Predictable  results No  under/over-­fetch type Query {

    hero (episode: Int): Character } { hero (episode: 4) { name homeWorld { name type } } } { "data" : { "hero" : { "name" : "Luke Skywalker" "homeWorld" : { "name" : "Tatooine" "type" : "desert" } } } type Character { name: String friends: [Character] homeWorld: Planet } type Planet { name: String type: String }
  3. GraphQL  vs  REST /carts/1?expand=products Server Update  endpoints Update  models HATEOAS

    /carts/1?fields=products(name,   description,   price) /cart_with_all_the_stuff_i_need /cart_version_2_with_all_the_things /cart_with_all_the_stuff_i_need_but_not_description
  4. GraphQL  vs  REST { cart { total products { name

    price quantity } } } { "data": { "cart" : { "total" : 27.00 "products" : [ { "name" : "Mug Black" "price" : 12.00 "quantity" : 1 }, { "name" : "Octocat figurine" "price" : 15.00 "quantity" : 1 } ] } }

More Decks by Bojan Tomić

Other Decks in Technology