SlideShare a Scribd company logo
1 of 25
Introduction to GraphQL
to enhance your APIs
Hi!
Dionysis
Technical Team Leader @jexia
Robert
Backend Developer @jexia
@robertignat
irobert91
linkedin.com/in/robertignat
@d3nnn1z
d3nnn1z
linkedin.com/in/d3nnn1z
Agenda
• Introduction to GraphQL
• Let’s build a server
• Advantages & Disadvantages
• Compared to REST
• Q&A
What is GraphQL?
GraphQL is a data query language and runtime designed
and used at Facebook to request and deliver data to
mobile and web apps since 2012.
No, you don’t have to use a graph db.
No, you don’t have to use a specific
server language.
How GraphQL works?
iOS App
Android App
Web App
Desktop App
GraphQL
Server
Data
Data
GraphQL
Queries
JSON
Payload
1
2
GraphQL Query Example
{
user(id: 123) {
name
email
friends {
id
name
}
}
}
{
“user”: {
“name”: “Wilma”,
“email”: “wilma@flintstones.com”,
“friends”: [
{
“id”: 124,
“name”: “Barney”
},
{
“id”: 132,
“name”: “Fred”
}
]
}
}
GraphQL query JSON Payload
Monkepark
You can use GraphQL with your existing backend!
Let’s build a server!
github.com/irobert91/monkepark-server-graphql
Advantages
Advantages
• What you see is what you get
• Client specific data
• Application layer protocol
• Strong typed
• Self documenting
• Existing backend APIs
• RFC - http://facebook.github.io/graphql
• Extra powers with Relay and React
• Introspection
• Active community
Disadvantages
Disadvantages
• Steep learning curve
• Overhead to manipulate the data
• No select *
• Args can become enormous
• Boilerplate
From REST to GraphQL
Mandrill
The mandrill has an olive
green or dark grey pelage
with yellow and black
bands and a white belly. Its
hairless face has an
elongated muzzle with
distinctive characteristics,
such as a red stripe down
the middle and protruding
blue ridges on the sides. It
also has red nostrils and
lips, a yellow beard and
white tufts.
Africa
REST
GET
/monkey/1
{
id: 1,
name: "Mandrill",
description: "The mandrill has...",
imageUrl: “mandrill.jpg”,
regions: [1],
...
}
GET
/regions/1
{
id: 1,
name: "Africa",
area: 30370000
}
GraphQL
{
name: "Mandrill",
description: "The mandrill has...",
imageUrl: “mandrill.jpg”,
regions: [
{
name: “Africa”
}
]
}
Mandrillus
The mandrill has an olive
green or dark grey pelage
with yellow and black
bands and a white belly. Its
hairless face has an
elongated muzzle with
distinctive characteristics,
such as a red stripe down
the middle and protruding
blue ridges on the sides. It
also has red nostrils and
lips, a yellow beard and
white tufts.
Africa
GraphQL
GraphQL JSON
{
monkey(id: 1) {
name
description
imageUrl
regions {
name
}
}
}
REQUEST
{
name: "Mandrill",
description: "The mandrill has...",
imageUrl: “mandrill.jpg”,
regions: [
{
name: “Africa”
}
]
}
RESPONSE
Custom Endpoints
Custom Endpoint 1 Custom Endpoint 2 Custom Endpoint 3
View 1 View 2 View 3
Custom Endpoints
Custom
Endpoint 1
Custom
Endpoint 2
Custom
Endpoint 3
Custom
Endpoint 4
Custom
Endpoint 5
Custom
Endpoint 6
View 1 View 2 View 3 View 4 View 5 View 6
Custom Endpoints
Custom Endpoint 1 Custom Endpoint 2 Custom Endpoint 3
View 1.1 View 2.1 View 3.1
Custom Endpoint 1.1 Custom Endpoint 2.1 Custom Endpoint 3.1
Custom Endpoints
Custom Endpoint 1 Custom Endpoint 2 Custom Endpoint 3
View 1.2 View 2.2 View 3.2
Custom Endpoint 1.1 Custom Endpoint 2.1 Custom Endpoint 3.1
Custom Endpoint 1.2 Custom Endpoint 2.2 Custom Endpoint 3.2
Custom Endpoints
GraphQL
GraphQL
View 1 View 2 View 3
Links
Github repo What?
github.com/facebook/graphql
The GraphQL specification, it’s not tied to a specific
implementation
github.com/graphql/graphql-js Node.js reference implementation by Facebook
github.com/graphql/graphiql
Web based IDE for GraphQL, cool features like
autocomplete
github.com/facebook/dataloader A data fetcher utility
github.com/chentsulin/awesome-graphql Awesome GraphQL
github.com/irobert91/monkepark-server Original monkepark server
github.com/irobert91/monkepark-server-graphql GraphQL monkepark
Thank you!
Questions?
Dionysis
Technical Team Leader @jexia
Robert
Backend Developer @jexia
@robertignat
irobert91
linkedin.com/in/robertignat
@d3nnn1z
d3nnn1z
linkedin.com/in/d3nnn1z

More Related Content

Similar to Introduction to GraphQL to enhance your APIs

Connecting the Netflix Studio with GraphQL
Connecting the Netflix Studio with GraphQLConnecting the Netflix Studio with GraphQL
Connecting the Netflix Studio with GraphQLCarlos Solares
 
Martin Junghans – Gradoop: Scalable Graph Analytics with Apache Flink
Martin Junghans – Gradoop: Scalable Graph Analytics with Apache FlinkMartin Junghans – Gradoop: Scalable Graph Analytics with Apache Flink
Martin Junghans – Gradoop: Scalable Graph Analytics with Apache FlinkFlink Forward
 
Gradoop: Scalable Graph Analytics with Apache Flink @ Flink Forward 2015
Gradoop: Scalable Graph Analytics with Apache Flink @ Flink Forward 2015Gradoop: Scalable Graph Analytics with Apache Flink @ Flink Forward 2015
Gradoop: Scalable Graph Analytics with Apache Flink @ Flink Forward 2015Martin Junghanns
 
Coral & Transport UDFs: Building Blocks of a Postmodern Data Warehouse​
Coral & Transport UDFs: Building Blocks of a Postmodern Data Warehouse​Coral & Transport UDFs: Building Blocks of a Postmodern Data Warehouse​
Coral & Transport UDFs: Building Blocks of a Postmodern Data Warehouse​Walaa Eldin Moustafa
 
Building Serverless GraphQL Backends
Building Serverless GraphQL BackendsBuilding Serverless GraphQL Backends
Building Serverless GraphQL BackendsNikolas Burk
 
Graphs & Big Data - Philip Rathle and Andreas Kollegger @ Big Data Science Me...
Graphs & Big Data - Philip Rathle and Andreas Kollegger @ Big Data Science Me...Graphs & Big Data - Philip Rathle and Andreas Kollegger @ Big Data Science Me...
Graphs & Big Data - Philip Rathle and Andreas Kollegger @ Big Data Science Me...Neo4j
 
Montreal Sql saturday: moving data from no sql db to azure data lake
Montreal Sql saturday: moving data from no sql db to azure data lakeMontreal Sql saturday: moving data from no sql db to azure data lake
Montreal Sql saturday: moving data from no sql db to azure data lakeDiponkar Paul
 
Designing and Running a GraphQL API
Designing and Running a GraphQL APIDesigning and Running a GraphQL API
Designing and Running a GraphQL APIAtlassian
 
Clojure/conj 2017
Clojure/conj 2017Clojure/conj 2017
Clojure/conj 2017Darren Kim
 
HBaseCon 2015: S2Graph - A Large-scale Graph Database with HBase
HBaseCon 2015: S2Graph - A Large-scale Graph Database with HBaseHBaseCon 2015: S2Graph - A Large-scale Graph Database with HBase
HBaseCon 2015: S2Graph - A Large-scale Graph Database with HBaseHBaseCon
 
GraphX: Graph Analytics in Apache Spark (AMPCamp 5, 2014-11-20)
GraphX: Graph Analytics in Apache Spark (AMPCamp 5, 2014-11-20)GraphX: Graph Analytics in Apache Spark (AMPCamp 5, 2014-11-20)
GraphX: Graph Analytics in Apache Spark (AMPCamp 5, 2014-11-20)Ankur Dave
 
Elasticsearch in 15 Minutes
Elasticsearch in 15 MinutesElasticsearch in 15 Minutes
Elasticsearch in 15 MinutesKarel Minarik
 
GraphQL & Prisma from Scratch
GraphQL & Prisma from ScratchGraphQL & Prisma from Scratch
GraphQL & Prisma from ScratchNikolas Burk
 
India software developers conference 2013 Bangalore
India software developers conference 2013 BangaloreIndia software developers conference 2013 Bangalore
India software developers conference 2013 BangaloreSatnam Singh
 
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...GreeceJS
 
[DevDay2019] Layering GraphQL on top of existing infrastructure - By Phan Tha...
[DevDay2019] Layering GraphQL on top of existing infrastructure - By Phan Tha...[DevDay2019] Layering GraphQL on top of existing infrastructure - By Phan Tha...
[DevDay2019] Layering GraphQL on top of existing infrastructure - By Phan Tha...DevDay.org
 
Overview of GraphQL & Clients
Overview of GraphQL & ClientsOverview of GraphQL & Clients
Overview of GraphQL & ClientsPokai Chang
 
The Tidyverse and the Future of the Monitoring Toolchain
The Tidyverse and the Future of the Monitoring ToolchainThe Tidyverse and the Future of the Monitoring Toolchain
The Tidyverse and the Future of the Monitoring ToolchainJohn Rauser
 
[263] s2graph large-scale-graph-database-with-hbase-2
[263] s2graph large-scale-graph-database-with-hbase-2[263] s2graph large-scale-graph-database-with-hbase-2
[263] s2graph large-scale-graph-database-with-hbase-2NAVER D2
 

Similar to Introduction to GraphQL to enhance your APIs (20)

Connecting the Netflix Studio with GraphQL
Connecting the Netflix Studio with GraphQLConnecting the Netflix Studio with GraphQL
Connecting the Netflix Studio with GraphQL
 
Martin Junghans – Gradoop: Scalable Graph Analytics with Apache Flink
Martin Junghans – Gradoop: Scalable Graph Analytics with Apache FlinkMartin Junghans – Gradoop: Scalable Graph Analytics with Apache Flink
Martin Junghans – Gradoop: Scalable Graph Analytics with Apache Flink
 
Gradoop: Scalable Graph Analytics with Apache Flink @ Flink Forward 2015
Gradoop: Scalable Graph Analytics with Apache Flink @ Flink Forward 2015Gradoop: Scalable Graph Analytics with Apache Flink @ Flink Forward 2015
Gradoop: Scalable Graph Analytics with Apache Flink @ Flink Forward 2015
 
Coral & Transport UDFs: Building Blocks of a Postmodern Data Warehouse​
Coral & Transport UDFs: Building Blocks of a Postmodern Data Warehouse​Coral & Transport UDFs: Building Blocks of a Postmodern Data Warehouse​
Coral & Transport UDFs: Building Blocks of a Postmodern Data Warehouse​
 
Building Serverless GraphQL Backends
Building Serverless GraphQL BackendsBuilding Serverless GraphQL Backends
Building Serverless GraphQL Backends
 
Graphs & Big Data - Philip Rathle and Andreas Kollegger @ Big Data Science Me...
Graphs & Big Data - Philip Rathle and Andreas Kollegger @ Big Data Science Me...Graphs & Big Data - Philip Rathle and Andreas Kollegger @ Big Data Science Me...
Graphs & Big Data - Philip Rathle and Andreas Kollegger @ Big Data Science Me...
 
Montreal Sql saturday: moving data from no sql db to azure data lake
Montreal Sql saturday: moving data from no sql db to azure data lakeMontreal Sql saturday: moving data from no sql db to azure data lake
Montreal Sql saturday: moving data from no sql db to azure data lake
 
Designing and Running a GraphQL API
Designing and Running a GraphQL APIDesigning and Running a GraphQL API
Designing and Running a GraphQL API
 
Clojure/conj 2017
Clojure/conj 2017Clojure/conj 2017
Clojure/conj 2017
 
HBaseCon 2015: S2Graph - A Large-scale Graph Database with HBase
HBaseCon 2015: S2Graph - A Large-scale Graph Database with HBaseHBaseCon 2015: S2Graph - A Large-scale Graph Database with HBase
HBaseCon 2015: S2Graph - A Large-scale Graph Database with HBase
 
GraphX: Graph Analytics in Apache Spark (AMPCamp 5, 2014-11-20)
GraphX: Graph Analytics in Apache Spark (AMPCamp 5, 2014-11-20)GraphX: Graph Analytics in Apache Spark (AMPCamp 5, 2014-11-20)
GraphX: Graph Analytics in Apache Spark (AMPCamp 5, 2014-11-20)
 
Elasticsearch in 15 Minutes
Elasticsearch in 15 MinutesElasticsearch in 15 Minutes
Elasticsearch in 15 Minutes
 
GraphQL & Prisma from Scratch
GraphQL & Prisma from ScratchGraphQL & Prisma from Scratch
GraphQL & Prisma from Scratch
 
India software developers conference 2013 Bangalore
India software developers conference 2013 BangaloreIndia software developers conference 2013 Bangalore
India software developers conference 2013 Bangalore
 
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
 
[DevDay2019] Layering GraphQL on top of existing infrastructure - By Phan Tha...
[DevDay2019] Layering GraphQL on top of existing infrastructure - By Phan Tha...[DevDay2019] Layering GraphQL on top of existing infrastructure - By Phan Tha...
[DevDay2019] Layering GraphQL on top of existing infrastructure - By Phan Tha...
 
Overview of GraphQL & Clients
Overview of GraphQL & ClientsOverview of GraphQL & Clients
Overview of GraphQL & Clients
 
Spark and MongoDB
Spark and MongoDBSpark and MongoDB
Spark and MongoDB
 
The Tidyverse and the Future of the Monitoring Toolchain
The Tidyverse and the Future of the Monitoring ToolchainThe Tidyverse and the Future of the Monitoring Toolchain
The Tidyverse and the Future of the Monitoring Toolchain
 
[263] s2graph large-scale-graph-database-with-hbase-2
[263] s2graph large-scale-graph-database-with-hbase-2[263] s2graph large-scale-graph-database-with-hbase-2
[263] s2graph large-scale-graph-database-with-hbase-2
 

Recently uploaded

Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...
Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...
Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...Abortion Clinic
 
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCAOpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCAShane Coughlan
 
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...Neo4j
 
Software Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements EngineeringSoftware Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements EngineeringPrakhyath Rai
 
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit MilanWorkshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit MilanNeo4j
 
Jax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined DeckJax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined DeckMarc Lester
 
A Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdfA Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdfICS
 
Encryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key ConceptsEncryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key Conceptsthomashtkim
 
Auto Affiliate AI Earns First Commission in 3 Hours..pdf
Auto Affiliate  AI Earns First Commission in 3 Hours..pdfAuto Affiliate  AI Earns First Commission in 3 Hours..pdf
Auto Affiliate AI Earns First Commission in 3 Hours..pdfSelfMade bd
 
The Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test AutomationThe Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test AutomationElement34
 
Weeding your micro service landscape.pdf
Weeding your micro service landscape.pdfWeeding your micro service landscape.pdf
Weeding your micro service landscape.pdftimtebeek1
 
Incident handling is a clearly defined set of procedures to manage and respon...
Incident handling is a clearly defined set of procedures to manage and respon...Incident handling is a clearly defined set of procedures to manage and respon...
Incident handling is a clearly defined set of procedures to manage and respon...Varun Mithran
 
Spring into AI presented by Dan Vega 5/14
Spring into AI presented by Dan Vega 5/14Spring into AI presented by Dan Vega 5/14
Spring into AI presented by Dan Vega 5/14VMware Tanzu
 
Rapidoform for Modern Form Building and Insights
Rapidoform for Modern Form Building and InsightsRapidoform for Modern Form Building and Insights
Rapidoform for Modern Form Building and Insightsrapidoform
 
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypseTomasz Kowalczewski
 
Workshop - Architecting Innovative Graph Applications- GraphSummit Milan
Workshop -  Architecting Innovative Graph Applications- GraphSummit MilanWorkshop -  Architecting Innovative Graph Applications- GraphSummit Milan
Workshop - Architecting Innovative Graph Applications- GraphSummit MilanNeo4j
 
GraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4jGraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4jNeo4j
 
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...naitiksharma1124
 
Automate your OpenSIPS config tests - OpenSIPS Summit 2024
Automate your OpenSIPS config tests - OpenSIPS Summit 2024Automate your OpenSIPS config tests - OpenSIPS Summit 2024
Automate your OpenSIPS config tests - OpenSIPS Summit 2024Andreas Granig
 

Recently uploaded (20)

Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...
Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...
Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...
 
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCAOpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
 
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
 
Software Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements EngineeringSoftware Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements Engineering
 
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit MilanWorkshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
 
Jax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined DeckJax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined Deck
 
A Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdfA Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdf
 
Encryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key ConceptsEncryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key Concepts
 
Auto Affiliate AI Earns First Commission in 3 Hours..pdf
Auto Affiliate  AI Earns First Commission in 3 Hours..pdfAuto Affiliate  AI Earns First Commission in 3 Hours..pdf
Auto Affiliate AI Earns First Commission in 3 Hours..pdf
 
The Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test AutomationThe Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test Automation
 
Weeding your micro service landscape.pdf
Weeding your micro service landscape.pdfWeeding your micro service landscape.pdf
Weeding your micro service landscape.pdf
 
Incident handling is a clearly defined set of procedures to manage and respon...
Incident handling is a clearly defined set of procedures to manage and respon...Incident handling is a clearly defined set of procedures to manage and respon...
Incident handling is a clearly defined set of procedures to manage and respon...
 
Spring into AI presented by Dan Vega 5/14
Spring into AI presented by Dan Vega 5/14Spring into AI presented by Dan Vega 5/14
Spring into AI presented by Dan Vega 5/14
 
Rapidoform for Modern Form Building and Insights
Rapidoform for Modern Form Building and InsightsRapidoform for Modern Form Building and Insights
Rapidoform for Modern Form Building and Insights
 
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
 
Abortion Clinic In Springs ](+27832195400*)[ 🏥 Safe Abortion Pills in Springs...
Abortion Clinic In Springs ](+27832195400*)[ 🏥 Safe Abortion Pills in Springs...Abortion Clinic In Springs ](+27832195400*)[ 🏥 Safe Abortion Pills in Springs...
Abortion Clinic In Springs ](+27832195400*)[ 🏥 Safe Abortion Pills in Springs...
 
Workshop - Architecting Innovative Graph Applications- GraphSummit Milan
Workshop -  Architecting Innovative Graph Applications- GraphSummit MilanWorkshop -  Architecting Innovative Graph Applications- GraphSummit Milan
Workshop - Architecting Innovative Graph Applications- GraphSummit Milan
 
GraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4jGraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4j
 
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
 
Automate your OpenSIPS config tests - OpenSIPS Summit 2024
Automate your OpenSIPS config tests - OpenSIPS Summit 2024Automate your OpenSIPS config tests - OpenSIPS Summit 2024
Automate your OpenSIPS config tests - OpenSIPS Summit 2024
 

Introduction to GraphQL to enhance your APIs

  • 1. Introduction to GraphQL to enhance your APIs
  • 2. Hi! Dionysis Technical Team Leader @jexia Robert Backend Developer @jexia @robertignat irobert91 linkedin.com/in/robertignat @d3nnn1z d3nnn1z linkedin.com/in/d3nnn1z
  • 3. Agenda • Introduction to GraphQL • Let’s build a server • Advantages & Disadvantages • Compared to REST • Q&A
  • 4. What is GraphQL? GraphQL is a data query language and runtime designed and used at Facebook to request and deliver data to mobile and web apps since 2012.
  • 5. No, you don’t have to use a graph db.
  • 6. No, you don’t have to use a specific server language.
  • 7. How GraphQL works? iOS App Android App Web App Desktop App GraphQL Server Data Data GraphQL Queries JSON Payload 1 2
  • 8. GraphQL Query Example { user(id: 123) { name email friends { id name } } } { “user”: { “name”: “Wilma”, “email”: “wilma@flintstones.com”, “friends”: [ { “id”: 124, “name”: “Barney” }, { “id”: 132, “name”: “Fred” } ] } } GraphQL query JSON Payload
  • 9. Monkepark You can use GraphQL with your existing backend! Let’s build a server! github.com/irobert91/monkepark-server-graphql
  • 11. Advantages • What you see is what you get • Client specific data • Application layer protocol • Strong typed • Self documenting • Existing backend APIs • RFC - http://facebook.github.io/graphql • Extra powers with Relay and React • Introspection • Active community
  • 13. Disadvantages • Steep learning curve • Overhead to manipulate the data • No select * • Args can become enormous • Boilerplate
  • 14. From REST to GraphQL Mandrill The mandrill has an olive green or dark grey pelage with yellow and black bands and a white belly. Its hairless face has an elongated muzzle with distinctive characteristics, such as a red stripe down the middle and protruding blue ridges on the sides. It also has red nostrils and lips, a yellow beard and white tufts. Africa
  • 15. REST GET /monkey/1 { id: 1, name: "Mandrill", description: "The mandrill has...", imageUrl: “mandrill.jpg”, regions: [1], ... } GET /regions/1 { id: 1, name: "Africa", area: 30370000 }
  • 16. GraphQL { name: "Mandrill", description: "The mandrill has...", imageUrl: “mandrill.jpg”, regions: [ { name: “Africa” } ] } Mandrillus The mandrill has an olive green or dark grey pelage with yellow and black bands and a white belly. Its hairless face has an elongated muzzle with distinctive characteristics, such as a red stripe down the middle and protruding blue ridges on the sides. It also has red nostrils and lips, a yellow beard and white tufts. Africa
  • 17. GraphQL GraphQL JSON { monkey(id: 1) { name description imageUrl regions { name } } } REQUEST { name: "Mandrill", description: "The mandrill has...", imageUrl: “mandrill.jpg”, regions: [ { name: “Africa” } ] } RESPONSE
  • 18. Custom Endpoints Custom Endpoint 1 Custom Endpoint 2 Custom Endpoint 3 View 1 View 2 View 3
  • 19. Custom Endpoints Custom Endpoint 1 Custom Endpoint 2 Custom Endpoint 3 Custom Endpoint 4 Custom Endpoint 5 Custom Endpoint 6 View 1 View 2 View 3 View 4 View 5 View 6
  • 20. Custom Endpoints Custom Endpoint 1 Custom Endpoint 2 Custom Endpoint 3 View 1.1 View 2.1 View 3.1 Custom Endpoint 1.1 Custom Endpoint 2.1 Custom Endpoint 3.1
  • 21. Custom Endpoints Custom Endpoint 1 Custom Endpoint 2 Custom Endpoint 3 View 1.2 View 2.2 View 3.2 Custom Endpoint 1.1 Custom Endpoint 2.1 Custom Endpoint 3.1 Custom Endpoint 1.2 Custom Endpoint 2.2 Custom Endpoint 3.2
  • 24. Links Github repo What? github.com/facebook/graphql The GraphQL specification, it’s not tied to a specific implementation github.com/graphql/graphql-js Node.js reference implementation by Facebook github.com/graphql/graphiql Web based IDE for GraphQL, cool features like autocomplete github.com/facebook/dataloader A data fetcher utility github.com/chentsulin/awesome-graphql Awesome GraphQL github.com/irobert91/monkepark-server Original monkepark server github.com/irobert91/monkepark-server-graphql GraphQL monkepark
  • 25. Thank you! Questions? Dionysis Technical Team Leader @jexia Robert Backend Developer @jexia @robertignat irobert91 linkedin.com/in/robertignat @d3nnn1z d3nnn1z linkedin.com/in/d3nnn1z

Editor's Notes

  1. Welcome to our GraphQL presentation.
  2. This is our agenda. We are going to start with a small introduction to GraphQL, then have a short live coding session to demonstrate what a server looks like. We’ll continue with advantages and disadvantages to using it and, of course, compare it to the most popular alternative, REST. In the end, there is going to be a Q&A.
  3. Nowadays building backend APIs practically means the mapping of the resources to URIs ( REST principles in mind ) GraphQL could help us go a step forward and make our APIs even more powerful. It is an application server with a standard type system and a standard API. This technology is still new and best practices are still emerging.
  4. The first thing that might come to mind when hearing the name are graph databases. GraphQL doesn’t force us to use a specific storage engine. It works equally using a relational db, a key-value store or even a graph database.
  5. GraphQL is language agnostic, it's just a specification between the client and the server. You can find implementations in many languages (node - reference implementation, golang, php, whatever).
  6. (After you explain it) Let’s see a GraphQL query example.
  7. GraphQL is a query language. It requests data which is then returned in the same shape it was queried in. As we can see, on the left we have a GraphQL query asking for the name, email and friends of user with id 123 and on the right we have the json response from the server. A key point here is that GraphQL allows us to use nested queries, like the friends.
  8. Monkepark is a Node.js project that we have created for a different presentation. Basically, it exposes a REST API to manage a list of monkeys, so we thought that it would be a good candidate to enhance with GraphQL. If you are interested in seeing the code, you can find both versions, with and without GraphQL, on github. Coding: GraphQL has a specific API and it involves some boilerplate code. Mention schema and types. Write the query part. Start the server. Show GraphiQL and explain it. Because GraphQL has an introspection API, GraphiQL makes use of this and provides features like autocompletion and documentation. Test the queries. Explain mutations in code. They are separated, but they have the same api as query. Exemplify mutations in GraphiQL. Now let’s see some cool stuff: Introspection, aliases, fragments, multiple queries. I mentioned an introspection API earlier, which is a nice feature of GraphQL, so let’s see how that works. Show __schema and __type(name: “Monkey”)
  9. What you see: Easy declarative way to describe data structure, the query looks just like the data it returns. Client specific data: A GraphQL query returns exactly what a client asks for and no more. Application layer protocol: GraphQL doesn’t require a specific transport, it’s just a string that is parsed and interpreted by the server. Strong type: GraphQL is strong typed. One: It allows a very good tooling system to prevent you from many errors! Second: the server can make certain guarantees about the queries and responses Self documenting: Exploring data becomes trivial. Existing backend APIs: designed to work with existing backend APIs RFC: It has a clear spec Extra powers with Relay and React: When you are going to search for graphql you are going to meet Relay and React. You have probably heard of React. Relay is a glue layer between React frontends and GraphQL servers. Ofc you can use graphql without those tools but if you use them you are going to have a better way to interact with your data and build strong UI components Introspection: You can easily explore the schema to see what fields you can query for Active community: GraphQL has an active open source community, with many online examples
  10. Steep learning curve: You have to get familiar with the GraphQL API and terminology in order to start building your GraphQL server! Overhead to manipulate data: After grabbing the data, the GraphQL server will filter and manipulate it before sending it to the client. No select *: Fields need to be specified in each query, there is no way to just return all of them. You can use fragments to avoid repeating writing again and again the same type, but it’s not an equivalent solution. Args: The more querying functionality the server has, the longer the args list can get. Boilerplate: Because of strong typed field definitions you have to deal with a lot of boilerplate code.
  11. So let’s see how GraphQL compares to REST. Suppose that we have to create this widget, a card that displays information for a specific monkey.
  12. Let’s see how to achieve it using a REST API. Although there is no strict definition of what rest means, in a simplified form we can think of it as resources and their representations. So let’s go back to see what data we need to create this widget. “Click” So we can see that we need at least 2 round trips to the server in order to get all the information to power this widget. “Click” It would be nice to just call the server once and have a payload like this
  13. Just get me the monkey details and the regions in order to render my view.
  14. This is where graphql shines! With GraphQL a frontend can ask for only the data that it needs, even if it’s nested, in only one call.
  15. Ofc another different approach when you are dealing with web services in order to avoid multiple round trips to the server is to have some custom endpoints for the specific view data. But usually we are building new features or we are iterating over existing features and this workflow introduces a new kind of problem. “Click”
  16. As you can see on this slide we just added more views so we had to add some more custom endpoints. And this is only for incrementally adding new features, let’s see when we have to deal with iterations over existing features.
  17. So you can imagine that after some point you get this “Click”
  18. So you can imagine that after some point you get this “Click”
  19. So you can imagine that after some point your API is like this!
  20. In graphql we don’t need an endpoint per view Most of the cases we don’t need to touch the server and if we need we touch it is to add some more types. One of the key problems GraphQL aims to solve is the idea of only making one API request to get all data needed, instead of constructing custom endpoints per use case. With GraphQL you expose a single endpoint to parse and execute the query. Then that query is executed over a type system which you can also access through the Introspection API.
  21. Under our experiments we found a lot repositories and links regarding graphql. We found it a little bit confusing to have to deal with all those different repos and what is what so we decided to put a slide here with all the repositories that we found useful in order to get started with graphql.