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
Tweet

More Decks by Orjiewuru Kingdom Isaac

Other Decks in Technology

Transcript

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

    Sourcerer • github.com/kingisaac95 • Twitter @kingisaac95
  2. • What is GraphQL? • GraphQL Features a. Fields &

    Variables b. Aliases & Directives c. Fragments • Demo of GraphQL querying using GraphiQL
  3. 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
  4. 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
  5. 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
  6. 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.
  7. Complex fields: Fields that contain other data in them. They

    usually have a custom type defined in the service’s schema. GraphQL fields
  8. 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>
  9. 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
  10. 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
  11. Fragments GraphQL’s reusable units for constructing sets of fields and

    including them in queries. Is it raining? Oh dear, please stay DRY!!!
  12. 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/