Introduction to GraphQL

Introduction to GraphQL

Learn about GraphQL, how it works, and how to use it.

4cae070608be3489262fe419c03498dc?s=128

Adrián Matellanes

September 23, 2017
Tweet

Transcript

  1. 2.

    GET https://2017.es.pycon.org/speakers/me { "name": "Adrián Matellanes", "roles": [ "Lead API

    Developer", "Málaga Python Organizer" ], "worksAt": "Ebury", "twitter": "@_amatellanes", "github": "github.com/amatellanes" }
  2. 12.

    "url": "http://anapioficeandfire.com/api/characters/583", "name": "Jon Snow", "culture": "Northmen", "born": "In 283

    AC", "titles": [ "Lord Commander of the Night's Watch" ], "aliases": [ "Lord Snow", "Ned Stark's Bastard", "The Snow of Winterfell", "The Bastard of Winterfell", "Lord Crow" ], "allegiances": [ "http://anapioficeandfire.com/api/houses/362" ], "books": [ "http://anapioficeandfire.com/api/books/5" ], "povBooks": [ "http://anapioficeandfire.com/api/books/1", "http://anapioficeandfire.com/api/books/2", "http://anapioficeandfire.com/api/books/3", "http://anapioficeandfire.com/api/books/8"
  3. 14.
  4. 22.
  5. 24.

    Created July 1, 2015 Updated September 20, 2017 381 Forks

    6,078 Stars 302 Commits 82 Open Issues https://github.com/facebook/graphql
  6. 25.
  7. 27.
  8. 28.
  9. 29.
  10. 30.
  11. 31.
  12. 32.
  13. 33.
  14. 34.
  15. 35.
  16. 36.
  17. 37.
  18. 54.

    type Character { name: String! house: House! } type House

    { name: String! words: String! members: [Character]! }
  19. 55.

    type Character { name: String! house: House! } type House

    { name: String! words: String! members: [Character]! } Object Type
  20. 56.

    type Character { name: String! house: House! } type House

    { name: String! words: String! members: [Character]! } Fields
  21. 57.

    type Character { name: String! house: House! } type House

    { name: String! words: String! members: [Character]! } Return Types
  22. 64.

    query CharactersNameAndHouse { allCharacters { name house { words }

    } } { "data": { "allCharacters": [ { "name": "Daenerys Targaryen", "house": { "words": "Fire and Blood" } }, { "name": "Jon Snow", "house": { "words": "Winter Is Coming" } } ] } }
  23. 68.
  24. 71.

    mutation CharacterMutation { createCharacter(name: "Sansa Stark") { name } }

    { "data": { "createCharacter": { "name": "Sansa Stark" } } }
  25. 74.

    subscription NewCharacterSubscription { newCharacter { name } } { "data":

    { "newCharacter": { "name": "Tyrion Lannister" } } }
  26. 79.

    QUERY getHouse(id: 5) { name, words, members } HOUSE name

    words members [ { name }, { name } ] name name
  27. 80.

    QUERY getHouse(id: 5) { name, words, members } HOUSE name

    words members [ { name }, { name } ] CHARACTER name name
  28. 83.

    { "data": { "__type": { "name": "Book", "kind": "OBJECT", "fields":

    [ { "name": "title", "type": { "name": "String" } } ] } } } { __type(name: "Book") { name kind fields { name type { name } } } }
  29. 84.
  30. 85.
  31. 86.
  32. 88.

    Created September 24, 2015 Updated September 20, 2017 229 Forks

    2,356 Stars 1,219 Commits 87 Open Issues https://github.com/graphql-python/graphene
  33. 89.
  34. 90.
  35. 91.

    "It’s important to understand that it isn’t all or nothing.

    GraphQL is in our future, but it isn’t our exclusive future."