GraphQL 10% Project
Dustin McCraw
6/6/18
Api's and Client's
Written code for:
Apiv3
McFeely
Dozer
League Frontend
NextJenn
Rosetta
Erlond
I have seen all the challenges of writing both backend and clients
REST Api
Representational state transfer
Define "resources" with CRUD actions
Disadvantages with multiple clients:
- Overfetching
- Multiple calls for associated resources
- Create custom endpoints for different client needs
GraphQL
- GraphQL is a query language created at Facebook in 2012
- Open source way to define an API
- Standard way to provide the description of the data of your api and it lets clients request exactly what they need
- Came from the conflict between users' wanting to get all the information in one query vs the requirement to isolated REST calls
GraphQL
Advantages
- Retrieve only the data you need on consumer side
- Reduce the data volume returned by the server because you retrieve only what you need
- Reduce the number of calls to retrieve data by linking resources and aggregating queries
- Discover the schema you are querying
GraphQL
https://githubengineering.com/the-github-graphql-api/
Title Text
- Defines a data shape
- Hierarchical/Graph
- Strongly typed
- Protocol
- Introspective
Define Shape
Queries mirror their response.
The clients determine what data they need.
Hierarchical/Graph/Relational
GraphQL defines the relationships between the objects.
Clients can choose what relationships they need for their specific use case.
Strongly Typed
Each level of a query corresponds to a type. Each type has a set of available fields.
Define a Schema using scalar types
A Character has a non null name and a non null list of Episodes.
Schema takes care of all validation
Protocol
Open source standard between server and clients
Can be written in any backend language using any datastore.
Introspective
Query for the types it supports
10% Project: Olympus
An Elixir Umbrella project
-
Zeus: Phoenix Server using Absinthe
-
Hades: Ecto App (database)
-
Hermes: Rabbit consumer
Olympus
Why Elixir?
- BEAM
- Immutability
- Concurrency
Why Phoenix/Absinthe?
- Open Source/Standards
- Books
- Best Practices
- Slack channels
Client Libraries
- Apollo (js/mobile)
- Neuron (elixir)
- graphql-client (ruby)
Want to learn more?
-
#graphql channel
-
https://github.com/teamsnap/olympus
-
https://github.com/teamsnap/olympus-clients
-
Friday 10% time meeting
-
I am always free to talk graphql!
Thank you!
GraphQL 10% Project
By Dustin McCraw
GraphQL 10% Project
- 770