GraphQL
1 March 2018
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
GraphQL is a specification for a query language for APIs.
It is an alternative to REST.
GraphQL is in use by many notable companies, including
(if you care)
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
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
In practice, broken out into classes
N.B. this syntax is in flux
![](img/apollo.svg)
- 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