GRAPHQL
A Missing link in REST
Anubolu Sreekanth
@Tataatsu Idealabs
https://github.com/sreekanth-anubolu
What is GraphQL?
■ A query language for API
■ Ask for what you need, get exactly that
Misconceptions about GraphQL
■ GraphQL is not a Graph DB technology
■ GraphQL is not replacement of REST
■ It is not tied to any framework / language
■ Security – Authentication approach is same as
REST
Existing issues in REST?
First of all REST is great 
Issues and Gaps
■ Endless Endpoints (3500 APIs onTwitter)
■ Hard to maintainVersioning
■ Frontend Developers always find it hard
■ Multiple Roundtrips
■ Over fetching Data
■ Not agile enough
TypicalWeb Architecture
Lets try to build API for simple News Feed UI
Roundtrips are too many
Solution: Build new API that is specific to this
view.
SolvedTADAAAA
But, this API is tightly coupled to the UI
Now – Designer says lets not show tags, instead author IMG
We May Not:
• Mobile Apps are already consuming API
• So, for the new UI, we end-up over fetching data
in order to support backtracking. - Not a good
approach.
• Build new version API
UI will be changed. Should we modify
the API?
Wouldn’t it be nice if we get what we
request?
Too Many UI iterations… Developers
look at Designers…
So, REST is not greatly adoptable for
rapid development.
Building new APIs for every change
involves effort and also increases
maintenance.
Very soon API maintenance becomes
complex.
Developer Friendliness
■ Its hard for new developers to understand the evolved
API.
■ We have to maintain documentation, for everyAPI we
build. Ex: Swagger
■ Effort Involved to document.
■ Frontend developers should always wait for Backend
to complete and it slows down the development
speed.
So it’s clear that these are the common
issues on REST
■ Endless Endpoints
■ Hard to maintainVersioning
■ Multiple Roundtrips
■ Over fetching Data
■ Not agile enough
■ Frontend Developers always find it hard
Well… GraphQL will address all of that.
GraphQL – A Missing Link in REST
GraphQL – A Query Language for API
■ GraphQL is a data query language open-sourced by Facebook
in 2015, internalized in Facebook back in 2012.
■ Today all Facebook mobile devices/clients are powered by
GraphQL.
■ GraphQL is built by keeping single endpoint in mind.
■ It follows a strict schematic and type system approach.
■ Queries should be written considering the Schema andTypes
How it works?
It is a beautiful query language, which lets us query for what we want and
response is ordered in same structure as we queried.
Example of Schema
Query Response
GraphQL doesn't stop us from talking to other services
Important Features and Batteries of GraphQL
■ Dataloader – Server side caching and Batch Query Processing
■ Subscribing to Server Side Events
■ GraphiQL – Browser based IDE for writing queries
■ Built-in documentation support with GraphiQL
■ Great support to many languages
■ Apollo for Angular/React – Great Performance
■ Support for Android/IOS
GraphQL In Action
https://github.com/sreekanth-anubolu/graphql-node-sqlite
Benefits of using GraphQL
■ Single Endpoint
■ Reduced Roundtrips – Faster than before
■ Can Batch Multiple Queries
■ No Over/Under fetching, get what you want
■ Freedom to front-end developers
■ Version free
■ Productive
■ Backward compatibility
■ Results Structured as Queried
GraphQL is platform agnostic
■ JavaScript/node-js (express-graphql for backend andApollo GraphQL for client apps
likeAngular/React/Vue/Polymer.. etc.)
■ Java
■ Python
■ C#/.NET
■ PHP
■ GO
■ Erlang
■ Groovy
■ Ruby
■ Scala
Who embraced the power of GraphQL?
Thanks
Questions?
Email - anubolusreekanth@gmail.com
Demo link - https://github.com/sreekanth-anubolu/graphql-node-sqlite

GraphQL - Missing Link In REST

  • 1.
    GRAPHQL A Missing linkin REST Anubolu Sreekanth @Tataatsu Idealabs https://github.com/sreekanth-anubolu
  • 2.
    What is GraphQL? ■A query language for API ■ Ask for what you need, get exactly that
  • 3.
    Misconceptions about GraphQL ■GraphQL is not a Graph DB technology ■ GraphQL is not replacement of REST ■ It is not tied to any framework / language ■ Security – Authentication approach is same as REST
  • 4.
    Existing issues inREST? First of all REST is great  Issues and Gaps ■ Endless Endpoints (3500 APIs onTwitter) ■ Hard to maintainVersioning ■ Frontend Developers always find it hard ■ Multiple Roundtrips ■ Over fetching Data ■ Not agile enough
  • 5.
  • 6.
    Lets try tobuild API for simple News Feed UI Roundtrips are too many
  • 7.
    Solution: Build newAPI that is specific to this view. SolvedTADAAAA But, this API is tightly coupled to the UI
  • 8.
    Now – Designersays lets not show tags, instead author IMG We May Not: • Mobile Apps are already consuming API • So, for the new UI, we end-up over fetching data in order to support backtracking. - Not a good approach. • Build new version API UI will be changed. Should we modify the API? Wouldn’t it be nice if we get what we request?
  • 9.
    Too Many UIiterations… Developers look at Designers…
  • 10.
    So, REST isnot greatly adoptable for rapid development. Building new APIs for every change involves effort and also increases maintenance. Very soon API maintenance becomes complex.
  • 11.
    Developer Friendliness ■ Itshard for new developers to understand the evolved API. ■ We have to maintain documentation, for everyAPI we build. Ex: Swagger ■ Effort Involved to document. ■ Frontend developers should always wait for Backend to complete and it slows down the development speed.
  • 12.
    So it’s clearthat these are the common issues on REST ■ Endless Endpoints ■ Hard to maintainVersioning ■ Multiple Roundtrips ■ Over fetching Data ■ Not agile enough ■ Frontend Developers always find it hard
  • 13.
    Well… GraphQL willaddress all of that. GraphQL – A Missing Link in REST
  • 14.
    GraphQL – AQuery Language for API ■ GraphQL is a data query language open-sourced by Facebook in 2015, internalized in Facebook back in 2012. ■ Today all Facebook mobile devices/clients are powered by GraphQL. ■ GraphQL is built by keeping single endpoint in mind. ■ It follows a strict schematic and type system approach. ■ Queries should be written considering the Schema andTypes
  • 15.
    How it works? Itis a beautiful query language, which lets us query for what we want and response is ordered in same structure as we queried.
  • 16.
  • 17.
  • 18.
    GraphQL doesn't stopus from talking to other services
  • 19.
    Important Features andBatteries of GraphQL ■ Dataloader – Server side caching and Batch Query Processing ■ Subscribing to Server Side Events ■ GraphiQL – Browser based IDE for writing queries ■ Built-in documentation support with GraphiQL ■ Great support to many languages ■ Apollo for Angular/React – Great Performance ■ Support for Android/IOS
  • 20.
  • 21.
    Benefits of usingGraphQL ■ Single Endpoint ■ Reduced Roundtrips – Faster than before ■ Can Batch Multiple Queries ■ No Over/Under fetching, get what you want ■ Freedom to front-end developers ■ Version free ■ Productive ■ Backward compatibility ■ Results Structured as Queried
  • 22.
    GraphQL is platformagnostic ■ JavaScript/node-js (express-graphql for backend andApollo GraphQL for client apps likeAngular/React/Vue/Polymer.. etc.) ■ Java ■ Python ■ C#/.NET ■ PHP ■ GO ■ Erlang ■ Groovy ■ Ruby ■ Scala
  • 23.
    Who embraced thepower of GraphQL?
  • 24.
    Thanks Questions? Email - anubolusreekanth@gmail.com Demolink - https://github.com/sreekanth-anubolu/graphql-node-sqlite