SlideShare a Scribd company logo
1 @luisw19
GraphQL as an
alternative
approach to
REST
About me
Luis Weir
CTO at Capgemini UK Oracle
Ace Director & Groundbreaker Ambassador
luis.weir@capgemini.com
uk.linkedin.com/in/lweir
http://www.soa4u.co.uk
apiplatform.cloud/
Released Q2 2018
tinyurl.com/eapim18
Goes to Print Q2 2019
• The 7 Deadly Sins of API Design
• Setting the vision, strategy and direction — the CTO’s role
• How can you design, deploy and manage your APIs?
• The Spotify's Engineering Culture. My interpretation and summary
• A comparison of API Gateways communication styles
• Is BPM Dead, Long Live Microservices?
• Five Minutes with Luis Weir
• 2nd vs 3rd Generation API Platforms - A Comprehensive
Comparison
• Podcast: Are Microservices and APIs Becoming SOA 2.0?
• 3rd-Generation API Management: From Proxies to Micro-Gateways
• Oracle API Platform Cloud Service Overview
Latest articles:
@luisw19
Want the slides? I’ll share via:
3 @luisw19© 2018 Capgemini. All rights reserved.
GraphQL as an alternative appraoch to REST
GraphQL – context & key
concepts
GraphQL vs REST PoV
01
03
Demos02
Conclusions04
4 @luisw19
Application Programming Interfaces (APIs) are doors to
information and functionality.
5 @luisw19
5
But some doors can be unfit for purpose…
source: https://imgur.com/a/J3ttg
01
6 @luisw19
6
Why GraphQL?
Source: https://dev-blog.apollodata.com/graphql-vs-rest-
5d425123e34b by Sashko Stubailo
01
7 @luisw19
7
GraphQL - Background
• Created by Facebook in 2012 to get around a common constraints in
the REST approach when fetching data
• Publicly released in 2015
• GraphQL Schema Definition Language (SDL) added to spec in Feb’18
Latest release: http://facebook.github.io/graphql
Latest draft: http://facebook.github.io/graphql/draft/
https://GraphQL.org
01
8 @luisw19
8
GraphQL – What is it NOT?
a query language
for a databases
in spite of its name, it
has nothing to do with
Graphs DBs
A silver Bullet
necessarily a
replacement for REST.
Both can work together
01
Roy from the IT Crowed à
9 @luisw19
9
GraphQL – What is it then?
A consumer oriented query language, a strongly typed schema
language and a runtime to implement GraphQL services.
Define Schema
type Country {
id: ID!
name: String!
code: String!
}
type query {
countries:
[Country]
}
GraphQL Service GraphQL Client
Quickly write and
run queries
{
getCountries(name:"great")
{
name
}
}
GraphQL Client
Get exactly what
you asked for
{
"data": {
"countries": [
{
"name": "United
Kingdom"
}
]
}
}
01
10 @luisw19
10
Who is using it?
Lots of organisations are embracing GraphQL: http://graphql.org/users
01
11 @luisw19
11
Increasing rapidly in Popularity
https://trends.google.com/trends/explore?date=2016-01-01%202018-12-01&q=GraphQL,REST%20API,OData
GraphQL REST API OData
Jan 2016 Dec 2018
01
12 @luisw19
12
Let’s put it into perspective
https://trends.google.com/trends/explore?date=2004-01-10%202018-11-30&q=GraphQL,REST%20API,OData,WSDL
trend
WSDL
01
GraphQL REST API OData
Feb 2004 Sep 2018
13 @luisw19
13
GraphQL – Key Concepts
There are 5 key characteristics of GraphQL that are
important to understand:
Hierarchical
Queries as
hierarchies of
data definitions,
shaped just how
data is expected
to be retuned.
1
View-centric
By design built to
satisfy frontend
application
requirements.
2
Strongly-typed
A GraphQL
server defines a
specific type
system. Queries
are executed
within this
context.
3 4
Introspective
The type system
itself is
queryable. Tools
are built around
this capability.
5
Version-Free
GraphQL takes a
strong opinion
on avoiding
versioning by
providing the
tools for the
continuous
evolution.
01
14 @luisw19
GraphQL
Server
Implementation
GraphQL
Schema
Definition
Language
GraphQL
Schema
(Data) Types
(Object, Input, Scalar,
Enum, Interface, Union)
Queries
(operation type)
Mutations
(operation type)
Resolvers
f(x), f(x), f(x)
Subscriptions
(operation type)
Define
Types
have
have
have
Execute
14
GraphQL – Anatomy
01
15 @luisw19
GraphQL
Server
Implementation
GraphQL
Schema
Definition
Language
GraphQL
Schema
(Data) Types
(Object, Input, Scalar,
Enum, Interface, Union)
Queries
(operation type)
Mutations
(operation type)
Resolvers
f(x), f(x), f(x)
Subscriptions
(operation type)
Define
Types
have
have
have
Execute
15
GraphQL – Anatomy
Effectively the blueprint of
a GraphQL API, it defines
the Types, Queries and
Mutations supported in a
GraphQL service
1
01
16 @luisw19
GraphQL
Server
Implementation
GraphQL
Schema
Definition
Language
GraphQL
Schema
(Data) Types
(Object, Input, Scalar,
Enum, Interface, Union)
Queries
(operation type)
Mutations
(operation type)
Resolvers
f(x), f(x), f(x)
Subscriptions
(operation type)
Define
Types
have
have
have
Execute
16
GraphQL – Anatomy
Object, Input, Scalar, Enumeration,
Interfaces and Unions are all types
to define data structures, which are
used in Operation types.
2
01
17 @luisw19
GraphQL
Server
Implementation
GraphQL
Schema
Definition
Language
GraphQL
Schema
(Data) Types
(Object, Input, Scalar,
Enum, Interface, Union)
Queries
(operation type)
Mutations
(operation type)
Resolvers
f(x), f(x), f(x)
Subscriptions
(operation type)
Define
Types
have
have
have
Execute
17
GraphQL – Anatomy
Entry point for operations that fetch
data (read / search). Note that a
single Query type can define
multiple query operations.
3
01
18 @luisw19
GraphQL
Server
Implementation
GraphQL
Schema
Definition
Language
GraphQL
Schema
(Data) Types
(Object, Input, Scalar,
Enum, Interface, Union)
Queries
(operation type)
Mutations
(operation type)
Resolvers
f(x), f(x), f(x)
Subscriptions
(operation type)
Define
Types
have
have
have
Execute
18
GraphQL – Key Concepts
Entry point for operations that
create/update data via a GraphQL
service. Note that a single Mutation
type can define multiple mutation
operations.
4
01
19 @luisw19
GraphQL
Server
Implementation
GraphQL
Schema
Definition
Language
GraphQL
Schema
(Data) Types
(Object, Input, Scalar,
Enum, Interface, Union)
Queries
(operation type)
Mutations
(operation type)
Resolvers
f(x), f(x), f(x)
Subscriptions
(operation type)
Define
Types
have
have
have
Execute
19
GraphQL – Anatomy
*new* Pub/sub system for near-
realtime updates. Unlike queries or
mutations, it can deliver more than
one result via push.
01
5
20 @luisw19
GraphQL
Server
Implementation
GraphQL
Schema
Definition
Language
GraphQL
Schema
(Data) Types
(Object, Input, Scalar,
Enum, Interface, Union)
Queries
(operation type)
Mutations
(operation type)
Resolvers
f(x), f(x), f(x)
Subscriptions
(operation type)
Define
Types
have
have
have
Execute
20
GraphQL – Anatomy
Functions that define how each
field, within a GraphQL Query or
Operation is to be acted upon.
6
01
21 @luisw19
21
GraphQL Schema Cheat Sheet
https://github.com/sogko/graphql-schema-language-cheat-sheet
01
22 @luisw19
22
Browser
GraphQL Client
Simple GraphQL Query Demo (I) - Mock
{
query
}
GraphQL Server:
Apollo/Express
GraphQL Service
Graphiql
GraphQL Schema
GraphQL Endpoint
http://.../graphiql
Query Operation {JSON}
[HTTP/POST]
{JSON}
{
data
}
https://github.com/luisw19/graphql-samples/tree/master/graphql-
countries-part1
02
Apollo Express: https://github.com/apollographql/apollo-server
23 @luisw19
23
Browser
GraphQL Client
Simple GraphQL Query Demo (II) – REST Backend
{
query
}
GraphQL Server:
Apollo/Express
GraphQL Service
Graphiql
GraphQL Schema
GraphQL Endpoint
Query Operation {JSON}
[HTTP/POST]
{JSON}
{
data
}
https://github.com/luisw19/graphql-samples/tree/master/graphql-
countries-part2
[HTTP/GET]
https://restcountries.eu/rest/v2/{resource}
{JSON}
REST COUNTRIES
02
24 @luisw19
24
Docker Container
Browser
GraphQL Client
Simple GraphQL Query Demo (III) - Mutation
{
query
}
GraphQL Server:
Apollo/Express
GraphQL Service
Graphiql
GraphQL Schema
GraphQL Endpoint
Query Operation {JSON}
[HTTP/POST]
{JSON}
{
data
}
https://github.com/luisw19/graphql-samples/tree/master/graphql-
countries-part3
[HTTP/GET]
https://restcountries.eu/rest/v2/{resource}
{JSON}
REST COUNTRIES
[HTTP/POST]
http://localhost:8000/{resource}
{JSON}
RequestBIN
02
25 @luisw19
25
Browser
GraphQL Client
Simple GraphQL Query Demo (IV) – API Composition
{
query
}
GraphQL Server:
Apollo/Express
GraphQL Service
Graphiql
GraphQL Schema
GraphQL Endpoint
Query Operation {JSON}
[HTTP/POST]
{JSON}
{
data
}
Not merged yet… (soon)
[HTTP/GET]
https://restcountries.eu/rest/v2/{resource}
{JSON}
REST COUNTRIES
[HTTP/POST]
https://www.google.co.uk/search?q={search}
{JSON}
02
26 @luisw19
26
GraphQL vs REST
GraphQL REST
(++) Usage: Best usage experience
for developers (Graphiql is brilliant!)
(~) API-first design: Tooling evolving
(build a service to mock).
(~) Usage: depends on the quality of
API definition and documentation
(+) API-first design: good tools
available (e.g. Apiary, Swagger
Hub).
Developer Experience
(design and consume APIs)
Design
Try
Build
API Composition
(query data from multiple sources)
API
(++) Perfectly suited for API
composition. Each field can be fetch
(in parallel) from any source in a
single query.
(--) The nature of REST makes it difficult
to model resources that combine data
structures from multiple sources. HATEOAS
results in chattiness.
(++) Brilliant
(+) Good
(~) Neutral (it depends)
(-) Not very good
(--) It sucks!
API Gateway
(API routing, security, policies)
(-) Existing Gateways have rich
support for REST, not yet GraphQL -
but could be used. Alternative is to
use a GraphQL Service as API
Gateway.
(++) API Gateways take away from
REST endpoints common tasks (e.g.
OAuth, API keys, throttling,
security).
API
API Gateway
API API
03
27 @luisw19
27
GraphQL vs REST
GraphQL REST
(++) Brilliant
(+) Good
(~) Neutral (it depends)
(-) Not very good
(--) It sucks!
Caching
(--) Network: unsuitable as there is
a common URL for all operations.
(+) Service: possible based on
Object Type (even fields) and in
mem cache like REDIS.
(++) Network: Caching is easy as
each resource is a unique URI.
Common tools can be used (e.g.
CDNs).
(+) Service: It’s equally possible at
service Level.
Network
Caching
App
Cache
Client
Back
End
Resource
(-) Standards like OAuth, OpenID
can be used however because all ops
can be accessed by single URI,
custom authorisation is typically
required.
(++) Major standards (OAuth 2,
OpenId) supported by API Gateways
and frameworks.
Authentication / Authorization
Client
Resource
Authorisation
Server
1
2
Versioning
(++) Best practices are clear.
Versioning should be avoided and
tools are provided (e.g. deprecation
of fields) for continuous evolution.
(-) Best practice less clear, in
practice URI based versioning very
popular although not encouraged.
03
28 @luisw19
28
GraphQL vs REST (completely subjective!)
GraphQL
REST
+++++++ (7)
~ (1)
---- (4)
++++++++ (8)
~~ (2)
--- (3)
à But it will only improve!
03
29 @luisw1929© 2018 Capgemini. All rights reserved.29
1
3
Conclusions
Still early days but GraphQL has huge potential
GraphQL takes away many of the headaches of dealing with
REST from a client side -specially around complex queries
(against multiple sources). However tooling specially around
API Design and API Gateways is still evolving. So bear this in
mind when considering GraphQL.
2
GraphQL and REST can work nicely together
There are thousands of REST APIs (external and internal) and
REST still is a viable and popular option. Instead of boiling the
ocean, as Roy said, GraphQL is not necessarily a replacement
for REST. As shown in this presentation both can be
complementary and work together nicely.
There is no silver bullets –do your own research
There is tons of information available in the GraphQL
Communities page. Explore it, learn about it and adopt it
based on your own criteria and requirements. And hope this
presentation helps in the process!
04
30 @luisw19
30
Resources
• GraphQL as an alternative approach to Rest recording at Devoxx’18 London
https://www.youtube.com/watch?v=hJOOdCPlXbU
• Github repository with the GraphQL tutorials
https://github.com/luisw19/graphql-samples
• Related articles:
• GraphQL with Oracle Database and node-oracledb by Christopher Jones
https://blogs.oracle.com/opal/demo%3a-graphql-with-node-oracledb
• GraphQL+OracleDB by Steven B
https://github.com/cloudsolutionhubs/oracledb-graphql-demo
31 @luisw19
With more than 190,000 people, Capgemini is present in over 40 countries and
celebrates its 50th Anniversary year in 2018. A global leader in consulting, technology
and outsourcing services, the Group reported 2016 global revenues of EUR 12.5 billion.
Together with its clients, Capgemini creates and delivers business, technology and
digital solutions that fit their needs, enabling them to achieve innovation and
competitiveness. A deeply multicultural organization, Capgemini has developed its own
way of working, the Collaborative Business Experience™, and draws on Rightshore®, its
worldwide delivery model.
About Capgemini
Learn more about us at
www.capgemini.com
This message contains information that may be privileged or confidential and is
the property of the Capgemini Group.
Copyright © 2018 Capgemini. All rights reserved.
Rightshore® is a trademark belonging to Capgemini.
This message is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to
read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please
notify the sender immediately and delete all copies of this message.

More Related Content

What's hot (20)

PDF
GraphQL: Enabling a new generation of API developer tools
Sashko Stubailo
 
PDF
React & GraphQL
Nikolas Burk
 
PPTX
Introduction to GraphQL
Rodrigo Prates
 
PDF
Graphql
Niv Ben David
 
PDF
How to GraphQL
Tomasz Bak
 
PDF
Getting Started with Spring for GraphQL
VMware Tanzu
 
PPTX
Intro GraphQL
Simona Cotin
 
PPTX
GraphQL Introduction
Serge Huber
 
PDF
GraphQL
Cédric GILLET
 
PDF
GraphQL Fundamentals
Virbhadra Ankalkote
 
PDF
Spring GraphQL
VMware Tanzu
 
PPTX
REST API
Tofazzal Ahmed
 
PPTX
B4USolution_API-Testing
b4usolution .
 
PDF
Api presentation
Tiago Cardoso
 
PDF
Better APIs with GraphQL
Josh Price
 
PDF
Microservices Integration Patterns with Kafka
Kasun Indrasiri
 
PDF
GraphQL vs REST
GreeceJS
 
PDF
REST API and CRUD
Prem Sanil
 
PDF
Apigee Demo: API Platform Overview
Apigee | Google Cloud
 
PDF
TypeScript - An Introduction
NexThoughts Technologies
 
GraphQL: Enabling a new generation of API developer tools
Sashko Stubailo
 
React & GraphQL
Nikolas Burk
 
Introduction to GraphQL
Rodrigo Prates
 
Graphql
Niv Ben David
 
How to GraphQL
Tomasz Bak
 
Getting Started with Spring for GraphQL
VMware Tanzu
 
Intro GraphQL
Simona Cotin
 
GraphQL Introduction
Serge Huber
 
GraphQL Fundamentals
Virbhadra Ankalkote
 
Spring GraphQL
VMware Tanzu
 
REST API
Tofazzal Ahmed
 
B4USolution_API-Testing
b4usolution .
 
Api presentation
Tiago Cardoso
 
Better APIs with GraphQL
Josh Price
 
Microservices Integration Patterns with Kafka
Kasun Indrasiri
 
GraphQL vs REST
GreeceJS
 
REST API and CRUD
Prem Sanil
 
Apigee Demo: API Platform Overview
Apigee | Google Cloud
 
TypeScript - An Introduction
NexThoughts Technologies
 

Similar to GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMonsters, UKOUG, AIOUG/Sangam) (20)

PDF
DEVOXX UK 2018 - GraphQL as an alternative approach to REST
luisw19
 
PDF
GraphQL
Deepak Shevani
 
PDF
Graphql usage
Valentin Buryakov
 
PPTX
GraphQL @ Manc.JS (March 2018)
Chris Grice
 
PDF
Tutorial: Building a GraphQL API in PHP
Andrew Rota
 
PDF
GraphQL in an Age of REST
Yos Riady
 
PDF
GraphQL and its schema as a universal layer for database access
Connected Data World
 
PDF
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
GreeceJS
 
PDF
Modern APIs with GraphQL
Taikai
 
PPTX
GraphQL research summary
Objectivity
 
PDF
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays
 
PDF
GraphQL over REST at Reactathon 2018
Sashko Stubailo
 
PDF
codersera_com (1).pdf
ThomasWilfred1
 
PDF
Serverless GraphQL for Product Developers
Sashko Stubailo
 
PDF
Real Time Serverless Polling App
Srushith Repakula
 
PDF
GraphQL with .NET Core Microservices.pdf
Knoldus Inc.
 
PDF
apidays LIVE Paris - The Rise of GraphQL for database APIs by Karthic Rao
apidays
 
PDF
GraphQL - A query language to empower your API consumers (NDC Sydney 2017)
Rob Crowley
 
DOCX
How has netflix embraced graph ql for rapid application development
jenniferCarnel1
 
PPTX
Austin API Summit 2018: Are REST APIs Still Relevant Today?
LaunchAny
 
DEVOXX UK 2018 - GraphQL as an alternative approach to REST
luisw19
 
Graphql usage
Valentin Buryakov
 
GraphQL @ Manc.JS (March 2018)
Chris Grice
 
Tutorial: Building a GraphQL API in PHP
Andrew Rota
 
GraphQL in an Age of REST
Yos Riady
 
GraphQL and its schema as a universal layer for database access
Connected Data World
 
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
GreeceJS
 
Modern APIs with GraphQL
Taikai
 
GraphQL research summary
Objectivity
 
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays
 
GraphQL over REST at Reactathon 2018
Sashko Stubailo
 
codersera_com (1).pdf
ThomasWilfred1
 
Serverless GraphQL for Product Developers
Sashko Stubailo
 
Real Time Serverless Polling App
Srushith Repakula
 
GraphQL with .NET Core Microservices.pdf
Knoldus Inc.
 
apidays LIVE Paris - The Rise of GraphQL for database APIs by Karthic Rao
apidays
 
GraphQL - A query language to empower your API consumers (NDC Sydney 2017)
Rob Crowley
 
How has netflix embraced graph ql for rapid application development
jenniferCarnel1
 
Austin API Summit 2018: Are REST APIs Still Relevant Today?
LaunchAny
 
Ad

More from luisw19 (8)

PDF
Proving API Value Through Monetization
luisw19
 
PDF
Changing the game in hospitality integrations
luisw19
 
PDF
The 7 Deadly Sins of API Design
luisw19
 
PDF
Spotify engineering culture summary
luisw19
 
PDF
Oracle API Platform Cloud Service Best Practices & Lessons Learnt
luisw19
 
PDF
Oracle Code Capgemini: API management & microservices a match made in heaven
luisw19
 
PDF
UKOUG - Implementing Enterprise API Management in the Oracle Cloud
luisw19
 
PDF
A microservice approach for legacy modernisation
luisw19
 
Proving API Value Through Monetization
luisw19
 
Changing the game in hospitality integrations
luisw19
 
The 7 Deadly Sins of API Design
luisw19
 
Spotify engineering culture summary
luisw19
 
Oracle API Platform Cloud Service Best Practices & Lessons Learnt
luisw19
 
Oracle Code Capgemini: API management & microservices a match made in heaven
luisw19
 
UKOUG - Implementing Enterprise API Management in the Oracle Cloud
luisw19
 
A microservice approach for legacy modernisation
luisw19
 
Ad

Recently uploaded (20)

PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Biography of Daniel Podor.pdf
Daniel Podor
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 

GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMonsters, UKOUG, AIOUG/Sangam)

  • 1. 1 @luisw19 GraphQL as an alternative approach to REST
  • 2. About me Luis Weir CTO at Capgemini UK Oracle Ace Director & Groundbreaker Ambassador [email protected] uk.linkedin.com/in/lweir http://www.soa4u.co.uk apiplatform.cloud/ Released Q2 2018 tinyurl.com/eapim18 Goes to Print Q2 2019 • The 7 Deadly Sins of API Design • Setting the vision, strategy and direction — the CTO’s role • How can you design, deploy and manage your APIs? • The Spotify's Engineering Culture. My interpretation and summary • A comparison of API Gateways communication styles • Is BPM Dead, Long Live Microservices? • Five Minutes with Luis Weir • 2nd vs 3rd Generation API Platforms - A Comprehensive Comparison • Podcast: Are Microservices and APIs Becoming SOA 2.0? • 3rd-Generation API Management: From Proxies to Micro-Gateways • Oracle API Platform Cloud Service Overview Latest articles: @luisw19 Want the slides? I’ll share via:
  • 3. 3 @luisw19© 2018 Capgemini. All rights reserved. GraphQL as an alternative appraoch to REST GraphQL – context & key concepts GraphQL vs REST PoV 01 03 Demos02 Conclusions04
  • 4. 4 @luisw19 Application Programming Interfaces (APIs) are doors to information and functionality.
  • 5. 5 @luisw19 5 But some doors can be unfit for purpose… source: https://imgur.com/a/J3ttg 01
  • 6. 6 @luisw19 6 Why GraphQL? Source: https://dev-blog.apollodata.com/graphql-vs-rest- 5d425123e34b by Sashko Stubailo 01
  • 7. 7 @luisw19 7 GraphQL - Background • Created by Facebook in 2012 to get around a common constraints in the REST approach when fetching data • Publicly released in 2015 • GraphQL Schema Definition Language (SDL) added to spec in Feb’18 Latest release: http://facebook.github.io/graphql Latest draft: http://facebook.github.io/graphql/draft/ https://GraphQL.org 01
  • 8. 8 @luisw19 8 GraphQL – What is it NOT? a query language for a databases in spite of its name, it has nothing to do with Graphs DBs A silver Bullet necessarily a replacement for REST. Both can work together 01 Roy from the IT Crowed à
  • 9. 9 @luisw19 9 GraphQL – What is it then? A consumer oriented query language, a strongly typed schema language and a runtime to implement GraphQL services. Define Schema type Country { id: ID! name: String! code: String! } type query { countries: [Country] } GraphQL Service GraphQL Client Quickly write and run queries { getCountries(name:"great") { name } } GraphQL Client Get exactly what you asked for { "data": { "countries": [ { "name": "United Kingdom" } ] } } 01
  • 10. 10 @luisw19 10 Who is using it? Lots of organisations are embracing GraphQL: http://graphql.org/users 01
  • 11. 11 @luisw19 11 Increasing rapidly in Popularity https://trends.google.com/trends/explore?date=2016-01-01%202018-12-01&q=GraphQL,REST%20API,OData GraphQL REST API OData Jan 2016 Dec 2018 01
  • 12. 12 @luisw19 12 Let’s put it into perspective https://trends.google.com/trends/explore?date=2004-01-10%202018-11-30&q=GraphQL,REST%20API,OData,WSDL trend WSDL 01 GraphQL REST API OData Feb 2004 Sep 2018
  • 13. 13 @luisw19 13 GraphQL – Key Concepts There are 5 key characteristics of GraphQL that are important to understand: Hierarchical Queries as hierarchies of data definitions, shaped just how data is expected to be retuned. 1 View-centric By design built to satisfy frontend application requirements. 2 Strongly-typed A GraphQL server defines a specific type system. Queries are executed within this context. 3 4 Introspective The type system itself is queryable. Tools are built around this capability. 5 Version-Free GraphQL takes a strong opinion on avoiding versioning by providing the tools for the continuous evolution. 01
  • 14. 14 @luisw19 GraphQL Server Implementation GraphQL Schema Definition Language GraphQL Schema (Data) Types (Object, Input, Scalar, Enum, Interface, Union) Queries (operation type) Mutations (operation type) Resolvers f(x), f(x), f(x) Subscriptions (operation type) Define Types have have have Execute 14 GraphQL – Anatomy 01
  • 15. 15 @luisw19 GraphQL Server Implementation GraphQL Schema Definition Language GraphQL Schema (Data) Types (Object, Input, Scalar, Enum, Interface, Union) Queries (operation type) Mutations (operation type) Resolvers f(x), f(x), f(x) Subscriptions (operation type) Define Types have have have Execute 15 GraphQL – Anatomy Effectively the blueprint of a GraphQL API, it defines the Types, Queries and Mutations supported in a GraphQL service 1 01
  • 16. 16 @luisw19 GraphQL Server Implementation GraphQL Schema Definition Language GraphQL Schema (Data) Types (Object, Input, Scalar, Enum, Interface, Union) Queries (operation type) Mutations (operation type) Resolvers f(x), f(x), f(x) Subscriptions (operation type) Define Types have have have Execute 16 GraphQL – Anatomy Object, Input, Scalar, Enumeration, Interfaces and Unions are all types to define data structures, which are used in Operation types. 2 01
  • 17. 17 @luisw19 GraphQL Server Implementation GraphQL Schema Definition Language GraphQL Schema (Data) Types (Object, Input, Scalar, Enum, Interface, Union) Queries (operation type) Mutations (operation type) Resolvers f(x), f(x), f(x) Subscriptions (operation type) Define Types have have have Execute 17 GraphQL – Anatomy Entry point for operations that fetch data (read / search). Note that a single Query type can define multiple query operations. 3 01
  • 18. 18 @luisw19 GraphQL Server Implementation GraphQL Schema Definition Language GraphQL Schema (Data) Types (Object, Input, Scalar, Enum, Interface, Union) Queries (operation type) Mutations (operation type) Resolvers f(x), f(x), f(x) Subscriptions (operation type) Define Types have have have Execute 18 GraphQL – Key Concepts Entry point for operations that create/update data via a GraphQL service. Note that a single Mutation type can define multiple mutation operations. 4 01
  • 19. 19 @luisw19 GraphQL Server Implementation GraphQL Schema Definition Language GraphQL Schema (Data) Types (Object, Input, Scalar, Enum, Interface, Union) Queries (operation type) Mutations (operation type) Resolvers f(x), f(x), f(x) Subscriptions (operation type) Define Types have have have Execute 19 GraphQL – Anatomy *new* Pub/sub system for near- realtime updates. Unlike queries or mutations, it can deliver more than one result via push. 01 5
  • 20. 20 @luisw19 GraphQL Server Implementation GraphQL Schema Definition Language GraphQL Schema (Data) Types (Object, Input, Scalar, Enum, Interface, Union) Queries (operation type) Mutations (operation type) Resolvers f(x), f(x), f(x) Subscriptions (operation type) Define Types have have have Execute 20 GraphQL – Anatomy Functions that define how each field, within a GraphQL Query or Operation is to be acted upon. 6 01
  • 21. 21 @luisw19 21 GraphQL Schema Cheat Sheet https://github.com/sogko/graphql-schema-language-cheat-sheet 01
  • 22. 22 @luisw19 22 Browser GraphQL Client Simple GraphQL Query Demo (I) - Mock { query } GraphQL Server: Apollo/Express GraphQL Service Graphiql GraphQL Schema GraphQL Endpoint http://.../graphiql Query Operation {JSON} [HTTP/POST] {JSON} { data } https://github.com/luisw19/graphql-samples/tree/master/graphql- countries-part1 02 Apollo Express: https://github.com/apollographql/apollo-server
  • 23. 23 @luisw19 23 Browser GraphQL Client Simple GraphQL Query Demo (II) – REST Backend { query } GraphQL Server: Apollo/Express GraphQL Service Graphiql GraphQL Schema GraphQL Endpoint Query Operation {JSON} [HTTP/POST] {JSON} { data } https://github.com/luisw19/graphql-samples/tree/master/graphql- countries-part2 [HTTP/GET] https://restcountries.eu/rest/v2/{resource} {JSON} REST COUNTRIES 02
  • 24. 24 @luisw19 24 Docker Container Browser GraphQL Client Simple GraphQL Query Demo (III) - Mutation { query } GraphQL Server: Apollo/Express GraphQL Service Graphiql GraphQL Schema GraphQL Endpoint Query Operation {JSON} [HTTP/POST] {JSON} { data } https://github.com/luisw19/graphql-samples/tree/master/graphql- countries-part3 [HTTP/GET] https://restcountries.eu/rest/v2/{resource} {JSON} REST COUNTRIES [HTTP/POST] http://localhost:8000/{resource} {JSON} RequestBIN 02
  • 25. 25 @luisw19 25 Browser GraphQL Client Simple GraphQL Query Demo (IV) – API Composition { query } GraphQL Server: Apollo/Express GraphQL Service Graphiql GraphQL Schema GraphQL Endpoint Query Operation {JSON} [HTTP/POST] {JSON} { data } Not merged yet… (soon) [HTTP/GET] https://restcountries.eu/rest/v2/{resource} {JSON} REST COUNTRIES [HTTP/POST] https://www.google.co.uk/search?q={search} {JSON} 02
  • 26. 26 @luisw19 26 GraphQL vs REST GraphQL REST (++) Usage: Best usage experience for developers (Graphiql is brilliant!) (~) API-first design: Tooling evolving (build a service to mock). (~) Usage: depends on the quality of API definition and documentation (+) API-first design: good tools available (e.g. Apiary, Swagger Hub). Developer Experience (design and consume APIs) Design Try Build API Composition (query data from multiple sources) API (++) Perfectly suited for API composition. Each field can be fetch (in parallel) from any source in a single query. (--) The nature of REST makes it difficult to model resources that combine data structures from multiple sources. HATEOAS results in chattiness. (++) Brilliant (+) Good (~) Neutral (it depends) (-) Not very good (--) It sucks! API Gateway (API routing, security, policies) (-) Existing Gateways have rich support for REST, not yet GraphQL - but could be used. Alternative is to use a GraphQL Service as API Gateway. (++) API Gateways take away from REST endpoints common tasks (e.g. OAuth, API keys, throttling, security). API API Gateway API API 03
  • 27. 27 @luisw19 27 GraphQL vs REST GraphQL REST (++) Brilliant (+) Good (~) Neutral (it depends) (-) Not very good (--) It sucks! Caching (--) Network: unsuitable as there is a common URL for all operations. (+) Service: possible based on Object Type (even fields) and in mem cache like REDIS. (++) Network: Caching is easy as each resource is a unique URI. Common tools can be used (e.g. CDNs). (+) Service: It’s equally possible at service Level. Network Caching App Cache Client Back End Resource (-) Standards like OAuth, OpenID can be used however because all ops can be accessed by single URI, custom authorisation is typically required. (++) Major standards (OAuth 2, OpenId) supported by API Gateways and frameworks. Authentication / Authorization Client Resource Authorisation Server 1 2 Versioning (++) Best practices are clear. Versioning should be avoided and tools are provided (e.g. deprecation of fields) for continuous evolution. (-) Best practice less clear, in practice URI based versioning very popular although not encouraged. 03
  • 28. 28 @luisw19 28 GraphQL vs REST (completely subjective!) GraphQL REST +++++++ (7) ~ (1) ---- (4) ++++++++ (8) ~~ (2) --- (3) à But it will only improve! 03
  • 29. 29 @luisw1929© 2018 Capgemini. All rights reserved.29 1 3 Conclusions Still early days but GraphQL has huge potential GraphQL takes away many of the headaches of dealing with REST from a client side -specially around complex queries (against multiple sources). However tooling specially around API Design and API Gateways is still evolving. So bear this in mind when considering GraphQL. 2 GraphQL and REST can work nicely together There are thousands of REST APIs (external and internal) and REST still is a viable and popular option. Instead of boiling the ocean, as Roy said, GraphQL is not necessarily a replacement for REST. As shown in this presentation both can be complementary and work together nicely. There is no silver bullets –do your own research There is tons of information available in the GraphQL Communities page. Explore it, learn about it and adopt it based on your own criteria and requirements. And hope this presentation helps in the process! 04
  • 30. 30 @luisw19 30 Resources • GraphQL as an alternative approach to Rest recording at Devoxx’18 London https://www.youtube.com/watch?v=hJOOdCPlXbU • Github repository with the GraphQL tutorials https://github.com/luisw19/graphql-samples • Related articles: • GraphQL with Oracle Database and node-oracledb by Christopher Jones https://blogs.oracle.com/opal/demo%3a-graphql-with-node-oracledb • GraphQL+OracleDB by Steven B https://github.com/cloudsolutionhubs/oracledb-graphql-demo
  • 31. 31 @luisw19 With more than 190,000 people, Capgemini is present in over 40 countries and celebrates its 50th Anniversary year in 2018. A global leader in consulting, technology and outsourcing services, the Group reported 2016 global revenues of EUR 12.5 billion. Together with its clients, Capgemini creates and delivers business, technology and digital solutions that fit their needs, enabling them to achieve innovation and competitiveness. A deeply multicultural organization, Capgemini has developed its own way of working, the Collaborative Business Experience™, and draws on Rightshore®, its worldwide delivery model. About Capgemini Learn more about us at www.capgemini.com This message contains information that may be privileged or confidential and is the property of the Capgemini Group. Copyright © 2018 Capgemini. All rights reserved. Rightshore® is a trademark belonging to Capgemini. This message is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.