This presentation focuses on giving an intro to and purpose of GraphQL. Built GraphQL server app with Nodejs. GIT LINK - https://github.com/sreekanth-anubolu/graphql-node-sqlite
1. GRAPHQL
A Missing link in 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 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
6. Lets try to build API for simple News Feed UI
Roundtrips are too many
7. Solution: Build new API that is specific to this
view.
SolvedTADAAAA
But, this API is tightly coupled to the UI
8. 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?
9. Too Many UI iterations… Developers
look at Designers…
10. 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.
11. 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.
12. 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
13. Well… GraphQL will address all of that.
GraphQL – A Missing Link in REST
14. 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
15. 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.
19. 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
21. 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
22. 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