GraphQL

1 March 2018

Meta

My goal is to explain and demonstrate GraphQL technology

It should take about 20 minutes, leaving us 10 minutes for discussion

These slides are available online

What is GraphQL?

GraphQL is a specification for a query language for APIs.

It is an alternative to REST.

Who uses GraphQL?

GraphQL is in use by many notable companies, including

(if you care)

Why GraphQL?

Specificity

We can request only those fields we will use


            

          

Predictability

The response format matches the the query


            

          

Efficiency

We can get more than one thing at a time


            

          

Discoverability

We can ask a GraphQL schema about itself

Reliability

We can stop versioning our API


            

          

            

          

Tools

graphql-ruby

A gem by Robert Mosolgo of GitHub which provides a GraphQL server implementation and a DSL for defining your schema.

rmosolgo/graphql-ruby

Basic graphql-ruby usage


        

In practice, broken out into classes


            

N.B. this syntax is in flux

  • A client-side library for React, iOS, and Android
  • A mock server to develop front-end code against
  • From Meteor Development Group

Basic Apollo usage example


        

GraphiQL

Provided by graphiql-rails gem, runs independently, also available as an Electron app

Summary

  • GraphQL is a spec for building an API
  • Advantages are specificity, predictability, efficiency, discoverability, and reliability
  • Back-end, front-end, and introspection tooling is available

The End