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

Getting started with GraphQL

Getting started with GraphQL

The 4th Weekly company-internal Agilize DevTalk of November, 2017.

Thiago Colares

November 24, 2017
Tweet

More Decks by Thiago Colares

Other Decks in Technology

Transcript

  1. Hallo! I’M THIAGO COLARES Agile manager Full stack developer Open

    source Co-founder @ Agilize Cloud Accounting @thicolares
  2. WHAT IS GRAPHQL ◦ Declarative data fetching ◦ Alternative to

    REST ◦ Single endpoint → responds to queries
  3. GraphQL TIMELINE ◦ Developed by Facebook on 2012 ◦ Presented

    → React.js Conf 2015 ◦ Is not for React Developers ◦ Other companies had the same initiative ◦ Netflix → Falcor ◦ Cousera → Now uses GraphQL
  4. REST CHALLENGES ◦ Need for efficient data loading (mobile) ◦

    Variety of different frontend frameworks ◦ Rapid feature development
  5. GraphQL BENEFITS ◦ No mover over or underfetching ◦ Almost

    non API if the interface changes ◦ Faster feedbacks cycles
  6. type Query { ... } type Mutation { ... }

    type Subscription { ... } ROOT TYPE
  7. { "data": { "User": { "name": "Joston Muriel", "posts": [

    {title: "Hello, it's me"} {title: "Lines in the sand"} ] } } } RESPONSE RESPONSE
  8. SCHEMA ◦ Strong type system ◦ Schema as client-server contract

    ◦ Client and server can work independently ◦ Schema Definition Language
  9. type Person { name: String! age: Int! } ADDING A

    RELATION type Post { title: String! author: Person! }
  10. type Person { name: String! age: Int! posts: [Post!]! }

    ADDING A HAS-MANY RELATION type Post { title: String! author: Person! }
  11. WRITING DATA WITH MUTATIONS ◦ A query too ◦ You

    can ask for the returning fields ◦ Even nested ones
  12. 3 KINDS OF MUTATIONS ◦ creating new data ◦ updating

    existing data ◦ deleting existing data
  13. A MUTATION mutation { createPerson(name: "Bob", age: 36) { name

    age } } Similar syntax. Mutation keyword. Special root field.