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

Let's talk GraphQL

Let's talk GraphQL

An introduction to GraphQL and it's features


Orjiewuru Kingdom Isaac

July 01, 2017


  1. Let’s Talk GraphQL A presentation on the underlying powers of

  2. • Orjiewuru Kingdom • Software Engineer @ Andela • Open

    Sourcerer • github.com/kingisaac95 • Twitter @kingisaac95
  3. What to expect:

  4. • What is GraphQL? • GraphQL Features a. Fields &

    Variables b. Aliases & Directives c. Fragments • Demo of GraphQL querying using GraphiQL
  5. What is GraphQL?

  6. A query language for your API • Developed internally by

    Facebook in 2012 • Publicly released in 2015 • Provides alternative for REST and ad-hoc web service architectures
  7. GraphQL is a data agent

  8. GraphQL Features

  9. Ask for what you need, get exactly that Request for

    a github user (Live Demo) • REST example - api.github.com/users/kingisaac95 • GraphQL example - graphqlhub.com/playground GraphQL queries return predictable results
  10. One request : Many resources With GraphQL you can access

    many API resources with just a single request. Example (Live Demo) Consuming Github and Twitter APIs with one request
  11. Strong type system GraphQL APIs are organized in terms of

    types and fields, not endpoints. Unlike RESTful APIs where an endpoint is defined for each resource, you can access the capabilities of your data from a single endpoint with GraphQL.
  12. GraphQL fields Scalar fields: Basic types that represent primitive values

    like string, integer, float, boolean.
  13. Complex fields: Fields that contain other data in them. They

    usually have a custom type defined in the service’s schema. GraphQL fields
  14. GraphQL Variables Variables are ehhhhmm, Variables They are identifiers for

    values used in our program, and in GraphQL, they let us avoid string interpolation and build dynamic queries. $<variable name>
  15. Aliases You cannot directly query the same field with different

    arguments in a single request. Aliases let you do that - rename the result of a field to anything you want. Example (Live Demo) Requesting for more than one user with a single request
  16. Directives What if you want to request for a particular

    field in a resource if a condition is met? @include @skip ...these are not Twitter handles
  17. Fragments GraphQL’s reusable units for constructing sets of fields and

    including them in queries. Is it raining? Oh dear, please stay DRY!!!
  18. Who is using GraphQL?

  19. Why should you learn GraphQL? Recap • Predictable results •

    Access many resources with one request • Conditional requests • Query single field with multiple arguments • Scaling your application Learn more graphql.org/learn/
  20. None