Jailbreak your API with GraphQL
Why GraphQL ?
6 dysfunctions of REST
Static
REST organisation
6 dysfunctions of REST
Static
Multiplication of endpoints
Multiplication of requests
6 dysfunctions of REST
Static
No typing
Versionning
Documentation
Multiplication of endpoints
Multiplication of requests
GraphQL to the rescue
Developed and used by Facebook since 2012
Open-source since 2016
Is becoming a new web standard
How does it works ?
1 unique endpoint
1 request
- fields
or
- operation to do
http://myapi/graphql
{
todos {
description,
isDone
}
}
Body
dynamic API
an unique request for
all the data you want
Structure
REST | GraphQL |
---|---|
|
|
1. We define the endpoints we want
2. We write the code for each endpoint
1. We build the graph structure by adding models or mutations
2. We write the code for each model
Automatic documentation
Strong typing
Simplified versionning
GraphiQL : "nice to have"
Demonstration
Live testing GraphiQL
Queries
Build the following page
Alias, Arguments
Mutations
Give a star to GraphQl repository
And more
- Fragments
- Directives
- Introspection
- Subscriptions
Get started
GraphQL is a specification
You can implement it in any language
Implementation for NodeJS, Java, PHP, Python...
And a community behind is already here
NodeJS implementation
1) Build Schema
Classic method
NodeJS implementation
1) Build Schema
2) Add logic
Classic method
NodeJS implementation
1) Build Schema
2) Add logic
3) Link everything
Classic method
You might not need GraphQL
Why GraphQL ?
Save time
Improve performance
Innovate
Thank you
Jailbreak your api with QraphQL
By Loïc Carbonne
Jailbreak your api with QraphQL
- 392