Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GraphQL: No REST For The Wicked

GraphQL: No REST For The Wicked

Avatar for Iyanuoluwa Ajao

Iyanuoluwa Ajao

July 21, 2018

More Decks by Iyanuoluwa Ajao

Other Decks in Programming

Transcript

  1. Who is this Guy? OTHER NAME; Ashiri EMPLOYER: AbbaandKing Systems

    LLC TWITTER, GITHUB, INSTAGRAM: @IyanuAshiri NOT SO SURPRISING FACT: I am suppose to be a Physiologist I just graduated from the best school in Nigeria
  2. 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. WHAT IS GRAPHQL
  3. REST is like buying food from Tantalizers. They give you

    a pack that includes what you may not like. If you want something else, then you have to buy another pack. GraphQL is like buying from a cafetaria.You buy what you want depending on your taste and the amount you can afford.
  4. Advantages of GraphQL Get the data you need and nothing

    more Get many resources in a single request because fields can be nested Strong typing means you can only ask for what is possible, hence making data handling safer
  5. Terminologies And Illustrations query ($login: String!) { user(login: $login) {

    bio repositoriesContributedTo(includeUserRepositories: false, privacy: PUBLIC, last: 10) { nodes { createdAt name description forkCount } } } repository (name: "Wikipedia-reference-scraper", owner: "iyanuashiri"){ name description forkCount pullRequests(first: 10){ nodes{ closed closedAt createdAt } } } } { "login": "iyanuashiri" }
  6. { "data": { "user": { "bio": "Python and Android developer

    ", "repositoriesContributedTo": { "nodes": [ { "createdAt": "2017-05-09T09:52:55Z", "name": "Code-Sleep-Python", "description": "Awesome Projects in Python", "forkCount": 121 }, { "createdAt": "2017-05-16T16:25:28Z", "name": "Python-Scripts", "description": "Collection of Various Python Script's.
  7. WHAT ABOUT THE SERVER? I don't do frontend...lol GraphQL allows

    you to describe schemas and an execution algorithm for how those queries will be executed.
  8. AN EXAMPLE OF A SCHEMA type Query { author(id: ID!):

    Author } type Author { posts: [Post] } type Post { title: String content: String }
  9. AN EXAMPLE QUERY FOR THE ABOVE SCHEMA query { author(id:

    "abc") { posts { title content } } }