SlideShare a Scribd company logo
1 of 60
Download to read offline
Build Scalable
APIs using
GraphQL and
Serverless
@simona_cotin
@simona_cotin
@simona_cotin
@simona_cotin
JS
@simona_cotin
@simona_cotin
@simona_cotin
@simona_cotin
–-Lee Byron
a data-fetching API powerful
enough to describe all of
Facebook
@simona_cotin
@simona_cotin
https://facebook.com/user/id
https://facebook.com/user/id/events
https://facebook.com/user/id/friends-suggestions
https://facebook.com/user/id/friends-birthdays
@simona_cotin
https://facebook.com/user/id/events
{
"name": “ServerlessDays",
"location": "Cardiff",
"organiser": "Matt",
"attendees": [
{
"name": “Ant Stanley",
"company": "!",
"role": “Father of ServerlessDays”
}
]
}
@simona_cotin
@simona_cotin
Overfetch
Or
New endpoint
@simona_cotin
@simona_cotin
https://facebook.com/user/id/friends-suggestions
{
"name": "Golnaz Badazadeh",
"profile_pic": "some_url",
"mutual_friends": []
}
@simona_cotin
https://facebook.com/user/id/friends-suggestions/id/mutual
{
"mutual_friends": [
{
"name": "Sarah Drasner",
"profile_pic": "some_url",
"tag": "Amazing!"
}
]
}
@simona_cotin
Underfetch
Or
New endpoint
@simona_cotin
Delay User Perception
0-100 ms Instant
100-300 ms Small perceptible delay
300-1000 ms Machine is working
1000+ ms Likely context switch
10000+ ms Task is abandoned
High performance Browser Networking
@simona_cotin
–-Ilya Grigorik
The fastest network request is a
request not made
@simona_cotin
query {
user(id:1) {
name
events {
count
}
friends_suggestions {
name
mutual_friends {
count
}
}
}
}
{
"data": {
"user": {
"name": "Simona Cotin",
"events": {
"count": 4
},
"friends_suggestions": {
"name": "Golnaz Babazadeh",
"mutual_friends": {
"count": 15
}
}
}
}
}
@simona_cotin
Schema driven
development
@simona_cotin
Strongly typed
@simona_cotin
type People {
id: ID!
name: String
avatar: URL
}
@simona_cotin
type People {
id: ID!
name: String
avatar: URL
}
type Team {
id: ID!
name: String
points: Int
people: [People]
}
@simona_cotin
type Query {
teams: [Team]
}
type Mutation {
incrementPoints(id: ID!): Team
}
@simona_cotin
const root = {
teams: async () =>" {
let teams = await axios.get(
'https://graphqlvoting.azurewebsites.net/
api/score'
);
return teams.data;
},
incrementPoints: async obj =>" {
let response = await axios.get(
`https://graphqlvoting.azurewebsites.net/
api/score/${obj.id}`
);
return response.data;
}
};
@simona_cotin
@simona_cotin
@simona_cotin
@simona_cotin
✓ Performance
✓ Flexibility
✓ Tooling
@simona_cotin
Serverless
@simona_cotin
–-Steve Jobs
The line of code that’s the
fastest to write, that never breaks,
that doesn’t need maintenance,
is the line you never had to write.
@simona_cotin
module.exports = async function(context, req) {
context.res = {
body: 'Hello ' + req.query.name
};
};
@simona_cotin
Right-Click
Deploy
@simona_cotin
Github
Deploy
@simona_cotin
@simona_cotin
Datasources
3rd party APIs
@simona_cotin
@simona_cotin
{
"type": "cosmosDB",
"name": "inputDocument",
"databaseName": "admin",
"collectionName": "Recipes",
"connectionStringSetting": "tacos-sql_DOCUMENTDB",
“direction": "in"
}
@simona_cotin
module.exports = async function(context, req) {
context.res = {
body: context.bindings.inputDocument
};
};
@simona_cotin
✓ Reusable API
✓ VS Code dev & debug
✓ Easy Integration
Datasources
@simona_cotin
No servers
to
manage
@simona_cotin
Serverless
@simona_cotin
@simona_cotin
@simona_cotin
@simona_cotin
@simona_cotin
@simona_cotin
module.exports = async function(context, req) {
const body = req.body;
let response = await graphql(
typeDefs,
body.query,
root,
null,
body.variables,
body.operationName
);
context.res = {
body: response
};
};
@simona_cotin
@simona_cotin
@simona_cotin
@simona_cotin
@simona_cotin
Easy Integration of Datasources
Autoscalability
Less code
Easy Abstraction of Datasources
Single Endpoint
Smaller no requests
Serverless GraphQL
@simona_cotin
Easy Integration of Datasources
Easy Abstraction of Datasources
Autoscalability
Single Endpoint
Less code
Smaller no requests
Dev productivity
@simona_cotin
Achieve more
by
doing less
@simona_cotin
https://github.com/simonaco/serverless-
graphql-workshop

More Related Content

More from Simona Cotin

Doppelganger - ng-conf
Doppelganger - ng-confDoppelganger - ng-conf
Doppelganger - ng-confSimona Cotin
 
Build a look alike engine with machine learning and Angular
Build a look alike engine with machine learning and AngularBuild a look alike engine with machine learning and Angular
Build a look alike engine with machine learning and AngularSimona Cotin
 
Hop on the serverless adventure - International Javascript London
Hop on the serverless adventure - International Javascript LondonHop on the serverless adventure - International Javascript London
Hop on the serverless adventure - International Javascript LondonSimona Cotin
 
Build progressive web apps with Angular
Build progressive web apps with AngularBuild progressive web apps with Angular
Build progressive web apps with AngularSimona Cotin
 
State management with ngRX
State management with ngRXState management with ngRX
State management with ngRXSimona Cotin
 
Deploy Angular to the Cloud (ngBucharest)
Deploy Angular to the Cloud (ngBucharest)Deploy Angular to the Cloud (ngBucharest)
Deploy Angular to the Cloud (ngBucharest)Simona Cotin
 
Build and Deploy Angular to the Cloud
Build and Deploy Angular to the CloudBuild and Deploy Angular to the Cloud
Build and Deploy Angular to the CloudSimona Cotin
 
Serverless adventure tooling
Serverless adventure toolingServerless adventure tooling
Serverless adventure toolingSimona Cotin
 
Code and Deploy Angular to the Cloud
Code and Deploy Angular to the CloudCode and Deploy Angular to the Cloud
Code and Deploy Angular to the CloudSimona Cotin
 
Deploy Angular to the Cloud
Deploy Angular to the CloudDeploy Angular to the Cloud
Deploy Angular to the CloudSimona Cotin
 
From Angular to React and back again
From Angular to React and back againFrom Angular to React and back again
From Angular to React and back againSimona Cotin
 

More from Simona Cotin (12)

Doppelganger - ng-conf
Doppelganger - ng-confDoppelganger - ng-conf
Doppelganger - ng-conf
 
Build a look alike engine with machine learning and Angular
Build a look alike engine with machine learning and AngularBuild a look alike engine with machine learning and Angular
Build a look alike engine with machine learning and Angular
 
Hop on the serverless adventure - International Javascript London
Hop on the serverless adventure - International Javascript LondonHop on the serverless adventure - International Javascript London
Hop on the serverless adventure - International Javascript London
 
Build progressive web apps with Angular
Build progressive web apps with AngularBuild progressive web apps with Angular
Build progressive web apps with Angular
 
State management with ngRX
State management with ngRXState management with ngRX
State management with ngRX
 
Deploy Angular to the Cloud (ngBucharest)
Deploy Angular to the Cloud (ngBucharest)Deploy Angular to the Cloud (ngBucharest)
Deploy Angular to the Cloud (ngBucharest)
 
Build and Deploy Angular to the Cloud
Build and Deploy Angular to the CloudBuild and Deploy Angular to the Cloud
Build and Deploy Angular to the Cloud
 
Serverless adventure tooling
Serverless adventure toolingServerless adventure tooling
Serverless adventure tooling
 
Code and Deploy Angular to the Cloud
Code and Deploy Angular to the CloudCode and Deploy Angular to the Cloud
Code and Deploy Angular to the Cloud
 
Deploy Angular to the Cloud
Deploy Angular to the CloudDeploy Angular to the Cloud
Deploy Angular to the Cloud
 
From Angular to React and back again
From Angular to React and back againFrom Angular to React and back again
From Angular to React and back again
 
Music Finder
Music FinderMusic Finder
Music Finder
 

Recently uploaded

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Recently uploaded (20)

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Build scalable APIs using GraphQL and Serverless @ ServerlessDays Cardiff