SlideShare a Scribd company logo
Wrapping and Securing
REST APIs with GraphQL
Nodejs Edinburgh Meetup
05/02/2019
What is this about?
@gethackteam
@gethackteam
Who Am I?
@gethackteam
@gethackteam
Roy Derks
@gethackteam
Auth0 Ambassador
#reactjs #ReactNative
#GraphQL
Who is this for?
@gethackteam
Who is this for?
BACKEND
@gethackteam
What is wrong with REST?
@gethackteam
REST has multiple
endpoints that return fixed
data structures
@gethackteam
Let’s look at an example
REST API
@gethackteam
What is wrong with REST?
Multiple Endpoints
@gethackteam
What is wrong with REST?
Multiple Endpoints
1
@gethackteam
What is wrong with REST?
Multiple Endpoints
1
2
@gethackteam
What is wrong with REST?
Multiple Endpoints
1
2
3
@gethackteam
Why not create one endpoint
with all information?
@gethackteam
What is wrong with REST?
Multiple Endpoints
@gethackteam
What is wrong with REST?
Multiple Endpoints
@gethackteam
What is wrong with REST?
Multiple Endpoints
@gethackteam
Why not specify parameters
you want to receive?
@gethackteam
What is wrong with REST?
Under/Over-fetching
@gethackteam
SHOW
What is wrong with REST?
Under/Over-fetching
@gethackteam
SHOW
What is wrong with REST?
Under/Over-fetching
@gethackteam
SHOW
What is wrong with REST?
Under/Over-fetching
2
1
@gethackteam
But how does this affect the first
version of the application?
@gethackteam
SHOW MORE
What is wrong with REST?
Versioning
V1 V2 @gethackteam
SHOW MORE
What is wrong with REST?
Versioning
V1 V2
Different endpoints
@gethackteam
SHOW MORE
What is wrong with REST?
Versioning
V1 V2
Different endpoints
@gethackteam
Different parameters
SHOW MORE
What is wrong with REST?
Versioning
V1 V2
Different endpoints
@gethackteam
Different parameters
Different datastructures
How does GraphQL
solve these problems?
@gethackteam
How does GraphQL
solve these problems?
Multiple Endpoints
@gethackteam
How does GraphQL
solve these problems?
Multiple Endpoints
Over-fetching
@gethackteam
How does GraphQL
solve these problems?
Multiple Endpoints
Under-fetching (N+1)
Over-fetching
@gethackteam
How does GraphQL
solve these problems?
Multiple Endpoints
Under-fetching (N+1)
Over-fetching Versioning /
Documentation@gethackteam
GraphQL has a single
endpoint that returns flexible
data structures
@gethackteam
How does GraphQL Solve This
Multiple Endpoints
@gethackteam
How does GraphQL Solve This
Multiple Endpoints
@gethackteam
How does GraphQL Solve This
Multiple Endpoints
GET
Query
@gethackteam
How does GraphQL Solve This
Multiple Endpoints
Mutation
POST PUT
PATCH DELETE
GET
Query
@gethackteam
How does GraphQL Solve This
Multiple Endpoints
Mutation
POST PUT
PATCH DELETE
GET
Query
@gethackteam
How does GraphQL Solve This
Single endpoint
How does GraphQL Solve This
Single endpoint
How does GraphQL Solve This
Single endpoint
Describe the data structure
How does GraphQL Solve This
Single endpoint
Describe the data structure
Set the possible queries
How does GraphQL Solve This
Single endpoint
How does GraphQL Solve This
Single endpoint
Set dynamic parameters
Specify which data
to return
How does GraphQL Solve This
Single endpoint
Set dynamic parameters
How does GraphQL Solve This
Single endpoint
How does GraphQL Solve This
Single endpoint
Predictable return result
Sounds great! How can I
implement this?
@gethackteam
BACKEND
Implementation
@gethackteam
BACKEND
Implementation
@gethackteam
Implementation
Existing services
Database(s)
Third-party API
@gethackteam
Implementation
Existing services
Database(s)
Third-party API
@gethackteam
Implementation
Existing services
Database(s)
Third-party API
@gethackteam
Implementation
@gethackteam
Implementation
@gethackteam
Node.js API Server
Implementation
@gethackteam
Node.js API Server
Apollo Express GraphQL Server
Implementation
@gethackteam
Implementation
Schemas
@gethackteam
Implementation
Schemas
@gethackteam
Match data 

to schema
Implementation
@gethackteam
Implementation
Retrieve data 

from source
@gethackteam
Implementation
Retrieve data 

from source
Get information

from headers
@gethackteam
Implementation
@gethackteam
Implementation
Initialise the

Node.js / GraphQL

server
@gethackteam
Data Sources
@gethackteam
Data Sources
@gethackteam
Data Sources
@gethackteam
Fetch REST endpoint
https://github.com/royderks/
auth0-graphql-rest/tree/
datasources
@gethackteam
Cool, let’s add Authentication
@gethackteam
Add Authentication
@gethackteam
Add Authentication
@gethackteam
Add Authentication
Middleware to validate JWT
@gethackteam
Add Authentication
Middleware to validate JWT
Retrieve key from JWT
@gethackteam
Add Authentication
Middleware to validate JWT
Retrieve key from JWT
Validate JWT scopes
@gethackteam
Add Authentication
@gethackteam
Add Authentication
Don’t break when token is 

incorrect or missing @gethackteam
Add Authentication
Don’t break when token is 

incorrect or missing
Add middleware to endpoint
@gethackteam
Add Authentication
@gethackteam
Add Authentication
Get information 

from headers @gethackteam
Add Authentication
Get information 

from headers @gethackteam
Add Authentication
Get information 

from headers Pass to REST endpoint @gethackteam
https://github.com/royderks/
auth0-graphql-rest
@gethackteam
To summarise..
@gethackteam
GraphQL can be built on top of
your existing data and code
@gethackteam
Want to learn more?
@gethackteam #javascriptEverywhere
https://auth0.com/
https://howtographql.com

More Related Content

PDF
Frontcon Riga - GraphQL Will Do To REST What JSON Did To XML
PDF
Kafka and GraphQL: Misconceptions and Connections | Gerard Klijs, Open Web
PDF
JNation: REST APIs to GraphQL with Express and Apollo
PDF
GraphQL + relay
PPTX
Machine Learning and Python For Marketing Automation | MKGO October 2019 | Ru...
PDF
RxJS - The Basics & The Future
PDF
Graphql
PDF
GraphQL over REST at Reactathon 2018
Frontcon Riga - GraphQL Will Do To REST What JSON Did To XML
Kafka and GraphQL: Misconceptions and Connections | Gerard Klijs, Open Web
JNation: REST APIs to GraphQL with Express and Apollo
GraphQL + relay
Machine Learning and Python For Marketing Automation | MKGO October 2019 | Ru...
RxJS - The Basics & The Future
Graphql
GraphQL over REST at Reactathon 2018

What's hot (20)

PDF
Serverless GraphQL for Product Developers
PDF
RxJS: A Beginner & Expert's Perspective - ng-conf 2017
PDF
Real-time GraphQL in Angular app
PDF
GraphQL & Relay
PDF
GraphQL With Relay Part Deux
PDF
GraphQL Without a Database | Frontend Developer Love
PDF
GraphQL across the stack: How everything fits together
PPTX
GraphQL Introduction
PPTX
GraphQL Introduction
PDF
Scaling your GraphQL applications with Dgraph
PDF
GraphQL Munich Meetup #1 - How We Use GraphQL At Commercetools
PDF
GraphQL Europe Recap
PDF
Introduction to GraphQL
PDF
React and GraphQL at Stripe
PDF
Adding GraphQL to your existing architecture
PDF
GraphQL
PPTX
React Flux to GraphQL
PDF
Web Applications of the Future with TypeScript and GraphQL
PDF
GraphQL: The Missing Link Between Frontend and Backend Devs
PPTX
Introduction to GraphQL
Serverless GraphQL for Product Developers
RxJS: A Beginner & Expert's Perspective - ng-conf 2017
Real-time GraphQL in Angular app
GraphQL & Relay
GraphQL With Relay Part Deux
GraphQL Without a Database | Frontend Developer Love
GraphQL across the stack: How everything fits together
GraphQL Introduction
GraphQL Introduction
Scaling your GraphQL applications with Dgraph
GraphQL Munich Meetup #1 - How We Use GraphQL At Commercetools
GraphQL Europe Recap
Introduction to GraphQL
React and GraphQL at Stripe
Adding GraphQL to your existing architecture
GraphQL
React Flux to GraphQL
Web Applications of the Future with TypeScript and GraphQL
GraphQL: The Missing Link Between Frontend and Backend Devs
Introduction to GraphQL
Ad

Similar to Wrapping and securing REST APIs with GraphQL (20)

PDF
GraphQL Will Do To REST What JSON Did To XML
PDF
GraphQL with .NET Core Microservices.pdf
PPTX
Introduction to Graph QL
PPTX
GraphQL - an elegant weapon... for more civilized age
PDF
PDF
GraphQL- Presentation
PPTX
apidays Munich 2025 - GraphQL 101: I won't REST, until you GraphQL, Surbhi Si...
PDF
apidays LIVE Paris - GraphQL meshes by Jens Neuse
PDF
APIsecure 2023 - Discovering GraphQL Vulnerabilities in the Wild, Tristan Kal...
PPTX
React inter3
PDF
The GrapQL ecosystem
PDF
GraphQL in an Age of REST
PPTX
GraphQL.pptx
PPTX
GraphQL.pptx
PDF
GraphQL Bangkok meetup 5.0
PDF
APIsecure 2023 - Learn how to attack and mitigate vulnerabilities in GraphQL,...
PPT
Graphql presentation
DOCX
GraphQL Advanced Concepts A Comprehensive Guide.docx
PDF
REST to GraphQL migration: Pros, cons and gotchas
PDF
Apollo server II
GraphQL Will Do To REST What JSON Did To XML
GraphQL with .NET Core Microservices.pdf
Introduction to Graph QL
GraphQL - an elegant weapon... for more civilized age
GraphQL- Presentation
apidays Munich 2025 - GraphQL 101: I won't REST, until you GraphQL, Surbhi Si...
apidays LIVE Paris - GraphQL meshes by Jens Neuse
APIsecure 2023 - Discovering GraphQL Vulnerabilities in the Wild, Tristan Kal...
React inter3
The GrapQL ecosystem
GraphQL in an Age of REST
GraphQL.pptx
GraphQL.pptx
GraphQL Bangkok meetup 5.0
APIsecure 2023 - Learn how to attack and mitigate vulnerabilities in GraphQL,...
Graphql presentation
GraphQL Advanced Concepts A Comprehensive Guide.docx
REST to GraphQL migration: Pros, cons and gotchas
Apollo server II
Ad

More from Roy Derks (14)

PDF
Web Applications of the Future: GraphQL and TypeScript | React Alicante
PDF
Why GraphQL is Perfect for Node.js Microservices - IJS London 2022
PDF
Why GraphQL Is Perfect For Microservices - CityJS London 2022
PDF
Workshop State-management in React with Context and Hooks
PDF
GraphQL Authentication
PDF
Web Applications of the Future with TypeScript and GraphQL
PDF
Wrapping and Securing REST APIs with GraphQL
PDF
Testing GraphQL in Your JavaScript Application: From Zero to Hundred Percent
PDF
Open-sourcing JavaScript at the City of Amsterdam - All Things Open 2019
PDF
We Are Developers - Modern React (Suspense, Context, Hooks) - Roy Derks
PDF
Handling Large-Scale State-Management with React Context and Hooks
PDF
Using ReasonML For Your Next JavaScript Project
PDF
Boilerplates Are The New Copy-Paste
PPTX
Workshop JavaScript ES6+
Web Applications of the Future: GraphQL and TypeScript | React Alicante
Why GraphQL is Perfect for Node.js Microservices - IJS London 2022
Why GraphQL Is Perfect For Microservices - CityJS London 2022
Workshop State-management in React with Context and Hooks
GraphQL Authentication
Web Applications of the Future with TypeScript and GraphQL
Wrapping and Securing REST APIs with GraphQL
Testing GraphQL in Your JavaScript Application: From Zero to Hundred Percent
Open-sourcing JavaScript at the City of Amsterdam - All Things Open 2019
We Are Developers - Modern React (Suspense, Context, Hooks) - Roy Derks
Handling Large-Scale State-Management with React Context and Hooks
Using ReasonML For Your Next JavaScript Project
Boilerplates Are The New Copy-Paste
Workshop JavaScript ES6+

Recently uploaded (20)

PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Cloud computing and distributed systems.
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Big Data Technologies - Introduction.pptx
PDF
Electronic commerce courselecture one. Pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Diabetes mellitus diagnosis method based random forest with bat algorithm
Cloud computing and distributed systems.
Network Security Unit 5.pdf for BCA BBA.
Review of recent advances in non-invasive hemoglobin estimation
Big Data Technologies - Introduction.pptx
Electronic commerce courselecture one. Pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Mobile App Security Testing_ A Comprehensive Guide.pdf
MYSQL Presentation for SQL database connectivity
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Unlocking AI with Model Context Protocol (MCP)
Reach Out and Touch Someone: Haptics and Empathic Computing
Chapter 3 Spatial Domain Image Processing.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx

Wrapping and securing REST APIs with GraphQL