SlideShare a Scribd company logo
Serverless GraphQL for Product
Developers
Take your productivity to the next level, on top
of your existing backends.
Sashko Stubailo, @stubailo
Open Source at Apollo, apollographql.com
Data management
is more important
than ever
UI
Data management
API
Backends and
storage
InternetNow that apps are built with
APIs and thick clients, it’s not
enough to just generate the
right HTML per-request.
From “How GraphQL Replaces Redux” by Mark Johnson on Medium
Multiple platforms and services
Backend Backend Backend Backend Backend
iOS Android Web VR Assistant
Loads of complexity in frontend tooling
Reducers
Sagas
Advanced requirements Disparate tools
Middleware
Selectors
Action creators
Thunks
Promises
Observables
Local state
Server-side rendering
Caching
Pagination
Offline
Optimistic UI
Error handling
Realtime
Mutations
Loading states
Apollo and GraphQL organize your data
Backend Backend Backend Backend Backend
iOS Android Web VR Assistant
Simplify frontend code
Reducers
Sagas
Middleware
Selectors
Action creators
Thunks
Promises
Observables
Local state
Server-side rendering
Caching
Pagination
Offline
Optimistic UI
Error handling
Realtime
Mutations
Loading states
const GET_DOGS = gql`
query {
dogs {
id
breed
displayImage
}
}
`;
const Feed = () => (
<Query query={GET_DOGS}>
{({ loading, error, data }) => {
if (loading) return <Fetching />;
if (error) return <Error />;
return <DogList data={data.dogs} />;
}}
</Query>
);
From “Reducing our Redux code with React Apollo” by Peggy Rayzis on Medium
How does GraphQL provide these benefits?
1. Schema describes
available data
2. Queries describe
requirements
3. Tools improve
productivity
type Dog {
id: String!
breed: String!
displayImage: String
images: [Image]
subbreeds: [String]
}
query {
dogs {
id
breed
displayImage
}
}
<Query query={X}>
({ data, error, loading }) => {
...
}
</Query>
OK, so how do we get this
in real life?
Put GraphQL over your
existing APIs
Continue to use your existing backends
Don’t re-implement business logic or
permissions rules
Make the translation layer as thin as possible, so
it doesn’t become a bottleneck
Diagram from Medium’s blog post:
GraphQL is a client-focused API
We’ve seen teams have the most success
when the API directly serves the needs of the
frontend
Empower frontend developers to add fields
as needed
Implement your GraphQL API in JavaScript
This means we need the GraphQL API to be
simple and fast to develop...
Apollo Server 2.0
➔ Dramatically simpler API
➔ Production optimizations built in
➔ Runs everywhere with the same code
Let’s implement GraphQL over REST for puppy photos
Define the
schemaUse the concise and readable
GraphQL schema language
const typeDefs = gql`
type Query {
dogs: [Dog]
dog(breed: String!): Dog
}
type Dog {
id: String!
breed: String!
displayImage: String
images: [Image]
subbreeds: [String]
}
type Image {
url: String!
id: String!
}
`;
Define a REST
data source
Caching and deduplication of
the API is handled for you
class DogAPI extends RESTDataSource {
baseURL = "https://dog.ceo/api";
async getDogs() {
const dogs = await this.get(`breeds/list/all`);
return _.map(dogs, createDog);
}
async getDisplayImage(breed) {
return this.get(`breed/${breed}/images/random`);
}
// ...
}
Write resolvers
Map data source methods to
the schema
const resolvers = {
Query: {
dogs: async (root, args, { dataSources }) => {
return dataSources.dogAPI.getDogs();
},
dog: async (root, { breed }, { dataSources }) => {
return dataSources.dogAPI.getDog(breed);
}
},
Dog: {
displayImage: async ({ breed }, args, { dataSources }) => {
return dataSources.dogAPI.getDisplayImage(breed);
},
images: async ({ breed }, args, { dataSources }) => {
return dataSources.dogAPI.getImages(breed);
}
}
};
Put them together
Now you’ve got a
production-ready GraphQL API
const server = new ApolloServer({
typeDefs,
resolvers,
dataSources: () => ({
dogAPI: new DogAPI()
})
});
Demo: Running locally
OK, so where do we deploy this layer?
Since we want to think of this as a thin translation layer that makes
our development more productive, we don’t want to worry about
managing and scaling servers or containers…
Serverless is a
perfect fit for
GraphQL APIs!
Apollo Server runs on every
serverless provider:
➔ Lambda
➔ Azure Functions
➔ Google Cloud
UI
Apollo Client
Backends and
storage
Serverless
ApolloServer
Deploying UI and functions on Netlify
UI code
API code
CDN
AWS Lambda
Demo: Production deploy
Reducing friction in
API deployment
Netlify has made it not just easy to deploy
the API, but part of the same workflow as
frontend code
Deploy previews you’re used to for
frontend code for the API as well
Over time, I hope there are more options
that make API deployment accessible to
product developers
What about
monitoring?
You don’t want to just get performance
reports for a single endpoint.
You want to see the data in terms of how
you implemented the schema.
The fine-grained nature of GraphQL
enables you to see detailed information
about how your API is doing.
Apollo Engine: Tooling for GraphQL
➔ Monitor GraphQL resolvers for usage statistics,
performance, and errors
➔ Track schema changes over time
➔ Integrate into Slack, GitHub, Datadog, and more
Keep track of your
schema
GraphQL-focused performance tracing
Demo: Opening a PR with
a change
Deploying a new change is so easy, we’re gonna do it
right now! We’ll look for:
➔ Netlify deploy preview for frontend and
backend
➔ Engine schema check and diff
What about caching? The best option is to cache the underlying
REST calls, since those are already set up
to work with caching.
Serverless architectures don’t make it
easy to persist data across requests, but
we’ve got an answer!
Data Sources
➔ Modular pattern for accessing REST from GraphQL
➔ Built-in deduplication and data pipeline
➔ Caching built in with support for Redis and Memcached
Remember our
data source?
class DogAPI extends RESTDataSource {
baseURL = "https://dog.ceo/api";
async getDogs() {
const dogs = await this.get(`breeds/list/all`);
return _.map(dogs, createDog);
}
async getDisplayImage(breed) {
return this.get(`breed/${breed}/images/random`);
}
// ...
}
Caching backend
requests with
serverless
Apollo Server data sources
integrate with Redis, and you
can use any cloud provider
Reduce backend API requests
and speed up response times
UI
Apollo Client
Backends and
storage
Serverless
ApolloServer
Redis provider
Zooming out: Super productive development
Frontend
React for UI, Apollo for state
management, Netlify to deploy
API
Apollo Server 2.0 for GraphQL, Lambda with
Netlify functions for deployment, and Data
Sources + Redis for caching
Tooling
Apollo Engine for
performance tracing and
schema versioning
Improving your API and data
management will dramatically
increase velocity.
Key premise:
Reaching for the ideal
developer experience
React, Apollo, and serverless
technologies are coming together into a
simple and modern set of tools for:
➔ Data management
➔ API development
➔ API performance
➔ Deployment
➔ PR checks and previews
➔ Version tracking
➔ Performance tracking
What’s next? Two things...
They say
JavaScript can run
anywhere...
➔ Browser
➔ Mobile
➔ Server
➔ Cloud functions
➔ Google spreadsheets
And it turns out, now also
inside CDNs!
Apollo Server on
the edge
Bring your API and cache right
to your users
apollographql.com/edge
UI
Apollo Client
Backends and
storage
CloudFlare workers in
151 data centers
CDN cache
UI
Apollo Client
Next: Schema-based tooling
➔ The GraphQL schema describes the data available
➔ Engine keeps track of changes
➔ How can we use all this info to help you write your code?
Coming soon: Apollo for Visual Studio Code
Run queries and even realtime subscriptions
Get performance stats from your API as you type
A really productive API experience
We’re making using and developing
APIs fun and productive.
And serverless is going to be a big part of that.
github.com/apollographql • apollographql.com • @apollographql

More Related Content

What's hot

Taking Control of your Data with GraphQL
Taking Control of your Data with GraphQLTaking Control of your Data with GraphQL
Taking Control of your Data with GraphQL
Vinci Rufus
 
Graphql presentation
Graphql presentationGraphql presentation
Graphql presentation
Vibhor Grover
 
Graphql Intro (Tutorial and Example)
Graphql Intro (Tutorial and Example)Graphql Intro (Tutorial and Example)
Graphql Intro (Tutorial and Example)
Rafael Wilber Kerr
 
GraphQL + relay
GraphQL + relayGraphQL + relay
GraphQL + relay
Cédric GILLET
 
Graphql
GraphqlGraphql
Graphql
Niv Ben David
 
GraphQL Introduction
GraphQL IntroductionGraphQL Introduction
GraphQL Introduction
Serge Huber
 
GraphQL London January 2018: Graphql tooling
GraphQL London January 2018: Graphql toolingGraphQL London January 2018: Graphql tooling
GraphQL London January 2018: Graphql tooling
Søren Bramer Schmidt
 
GraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsGraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer tools
Sashko Stubailo
 
GraphQL
GraphQLGraphQL
GraphQL
Joel Corrêa
 
How to GraphQL: React Apollo
How to GraphQL: React ApolloHow to GraphQL: React Apollo
How to GraphQL: React Apollo
Tomasz Bak
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
Rodrigo Prates
 
REST vs GraphQL
REST vs GraphQLREST vs GraphQL
REST vs GraphQL
Squareboat
 
GraphQL & Relay
GraphQL & RelayGraphQL & Relay
GraphQL & Relay
Viacheslav Slinko
 
Intro to GraphQL
 Intro to GraphQL Intro to GraphQL
Intro to GraphQL
Rakuten Group, Inc.
 
React, GraphQL и Relay - вполне себе нормальный компонентный подход (nodkz)
React, GraphQL и Relay - вполне себе нормальный компонентный подход (nodkz)React, GraphQL и Relay - вполне себе нормальный компонентный подход (nodkz)
React, GraphQL и Relay - вполне себе нормальный компонентный подход (nodkz)
Pavel Chertorogov
 
James Baxley - Statically typing your GraphQL app
James Baxley - Statically typing your GraphQL appJames Baxley - Statically typing your GraphQL app
James Baxley - Statically typing your GraphQL app
React Conf Brasil
 
An intro to GraphQL
An intro to GraphQLAn intro to GraphQL
An intro to GraphQL
valuebound
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL Stack
Sashko Stubailo
 
How to GraphQL
How to GraphQLHow to GraphQL
How to GraphQL
Tomasz Bak
 
Better APIs with GraphQL
Better APIs with GraphQL Better APIs with GraphQL
Better APIs with GraphQL
Josh Price
 

What's hot (20)

Taking Control of your Data with GraphQL
Taking Control of your Data with GraphQLTaking Control of your Data with GraphQL
Taking Control of your Data with GraphQL
 
Graphql presentation
Graphql presentationGraphql presentation
Graphql presentation
 
Graphql Intro (Tutorial and Example)
Graphql Intro (Tutorial and Example)Graphql Intro (Tutorial and Example)
Graphql Intro (Tutorial and Example)
 
GraphQL + relay
GraphQL + relayGraphQL + relay
GraphQL + relay
 
Graphql
GraphqlGraphql
Graphql
 
GraphQL Introduction
GraphQL IntroductionGraphQL Introduction
GraphQL Introduction
 
GraphQL London January 2018: Graphql tooling
GraphQL London January 2018: Graphql toolingGraphQL London January 2018: Graphql tooling
GraphQL London January 2018: Graphql tooling
 
GraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsGraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer tools
 
GraphQL
GraphQLGraphQL
GraphQL
 
How to GraphQL: React Apollo
How to GraphQL: React ApolloHow to GraphQL: React Apollo
How to GraphQL: React Apollo
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
REST vs GraphQL
REST vs GraphQLREST vs GraphQL
REST vs GraphQL
 
GraphQL & Relay
GraphQL & RelayGraphQL & Relay
GraphQL & Relay
 
Intro to GraphQL
 Intro to GraphQL Intro to GraphQL
Intro to GraphQL
 
React, GraphQL и Relay - вполне себе нормальный компонентный подход (nodkz)
React, GraphQL и Relay - вполне себе нормальный компонентный подход (nodkz)React, GraphQL и Relay - вполне себе нормальный компонентный подход (nodkz)
React, GraphQL и Relay - вполне себе нормальный компонентный подход (nodkz)
 
James Baxley - Statically typing your GraphQL app
James Baxley - Statically typing your GraphQL appJames Baxley - Statically typing your GraphQL app
James Baxley - Statically typing your GraphQL app
 
An intro to GraphQL
An intro to GraphQLAn intro to GraphQL
An intro to GraphQL
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL Stack
 
How to GraphQL
How to GraphQLHow to GraphQL
How to GraphQL
 
Better APIs with GraphQL
Better APIs with GraphQL Better APIs with GraphQL
Better APIs with GraphQL
 

Similar to Serverless GraphQL for Product Developers

How to use apolloJS on React ?
How to use apolloJS on React ?How to use apolloJS on React ?
How to use apolloJS on React ?
Jonathan Jalouzot
 
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays
 
How easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performanceHow easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performance
Red Hat
 
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything togetherSashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
React Conf Brasil
 
Create GraphQL server with apolloJS
Create GraphQL server with apolloJSCreate GraphQL server with apolloJS
Create GraphQL server with apolloJS
Jonathan Jalouzot
 
Graphql usage
Graphql usageGraphql usage
Graphql usage
Valentin Buryakov
 
Create API for your Databases
Create API for your DatabasesCreate API for your Databases
Create API for your Databases
Cédrick Lunven
 
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? W...
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? W...apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? W...
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? W...
apidays
 
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
Choisir entre une API  RPC, SOAP, REST, GraphQL?  
Et si le problème était ai...Choisir entre une API  RPC, SOAP, REST, GraphQL?  
Et si le problème était ai...
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
François-Guillaume Ribreau
 
Scripting Oracle Develop 2007
Scripting Oracle Develop 2007Scripting Oracle Develop 2007
Scripting Oracle Develop 2007
Tugdual Grall
 
Drupalcon Mumbai
Drupalcon MumbaiDrupalcon Mumbai
Drupalcon Mumbai
Sumit Kataria
 
GraphQL @ Manc.JS (March 2018)
GraphQL @ Manc.JS (March 2018)GraphQL @ Manc.JS (March 2018)
GraphQL @ Manc.JS (March 2018)
Chris Grice
 
How has netflix embraced graph ql for rapid application development
How has netflix embraced graph ql for rapid application developmentHow has netflix embraced graph ql for rapid application development
How has netflix embraced graph ql for rapid application development
jenniferCarnel1
 
Deploying Web Apps with PaaS and Docker Tools
Deploying Web Apps with PaaS and Docker ToolsDeploying Web Apps with PaaS and Docker Tools
Deploying Web Apps with PaaS and Docker Tools
Eddie Lau
 
APIdays Paris 2019 - Delivering Exceptional User Experience with REST and Gra...
APIdays Paris 2019 - Delivering Exceptional User Experience with REST and Gra...APIdays Paris 2019 - Delivering Exceptional User Experience with REST and Gra...
APIdays Paris 2019 - Delivering Exceptional User Experience with REST and Gra...
apidays
 
Best of Microsoft Dev Camp 2015
Best of Microsoft Dev Camp 2015Best of Microsoft Dev Camp 2015
Best of Microsoft Dev Camp 2015
Bluegrass Digital
 
StrongLoop Overview
StrongLoop OverviewStrongLoop Overview
StrongLoop Overview
Shubhra Kar
 
Implementing OpenAPI and GraphQL services with gRPC
Implementing OpenAPI and GraphQL services with gRPCImplementing OpenAPI and GraphQL services with gRPC
Implementing OpenAPI and GraphQL services with gRPC
Tim Burks
 
Getting started with AWS amplify
Getting started with AWS amplifyGetting started with AWS amplify
Getting started with AWS amplify
Marc Schröter
 
Real Time Serverless Polling App
Real Time Serverless Polling AppReal Time Serverless Polling App
Real Time Serverless Polling App
Srushith Repakula
 

Similar to Serverless GraphQL for Product Developers (20)

How to use apolloJS on React ?
How to use apolloJS on React ?How to use apolloJS on React ?
How to use apolloJS on React ?
 
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
 
How easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performanceHow easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performance
 
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything togetherSashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
 
Create GraphQL server with apolloJS
Create GraphQL server with apolloJSCreate GraphQL server with apolloJS
Create GraphQL server with apolloJS
 
Graphql usage
Graphql usageGraphql usage
Graphql usage
 
Create API for your Databases
Create API for your DatabasesCreate API for your Databases
Create API for your Databases
 
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? W...
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? W...apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? W...
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? W...
 
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
Choisir entre une API  RPC, SOAP, REST, GraphQL?  
Et si le problème était ai...Choisir entre une API  RPC, SOAP, REST, GraphQL?  
Et si le problème était ai...
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
 
Scripting Oracle Develop 2007
Scripting Oracle Develop 2007Scripting Oracle Develop 2007
Scripting Oracle Develop 2007
 
Drupalcon Mumbai
Drupalcon MumbaiDrupalcon Mumbai
Drupalcon Mumbai
 
GraphQL @ Manc.JS (March 2018)
GraphQL @ Manc.JS (March 2018)GraphQL @ Manc.JS (March 2018)
GraphQL @ Manc.JS (March 2018)
 
How has netflix embraced graph ql for rapid application development
How has netflix embraced graph ql for rapid application developmentHow has netflix embraced graph ql for rapid application development
How has netflix embraced graph ql for rapid application development
 
Deploying Web Apps with PaaS and Docker Tools
Deploying Web Apps with PaaS and Docker ToolsDeploying Web Apps with PaaS and Docker Tools
Deploying Web Apps with PaaS and Docker Tools
 
APIdays Paris 2019 - Delivering Exceptional User Experience with REST and Gra...
APIdays Paris 2019 - Delivering Exceptional User Experience with REST and Gra...APIdays Paris 2019 - Delivering Exceptional User Experience with REST and Gra...
APIdays Paris 2019 - Delivering Exceptional User Experience with REST and Gra...
 
Best of Microsoft Dev Camp 2015
Best of Microsoft Dev Camp 2015Best of Microsoft Dev Camp 2015
Best of Microsoft Dev Camp 2015
 
StrongLoop Overview
StrongLoop OverviewStrongLoop Overview
StrongLoop Overview
 
Implementing OpenAPI and GraphQL services with gRPC
Implementing OpenAPI and GraphQL services with gRPCImplementing OpenAPI and GraphQL services with gRPC
Implementing OpenAPI and GraphQL services with gRPC
 
Getting started with AWS amplify
Getting started with AWS amplifyGetting started with AWS amplify
Getting started with AWS amplify
 
Real Time Serverless Polling App
Real Time Serverless Polling AppReal Time Serverless Polling App
Real Time Serverless Polling App
 

Recently uploaded

Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 

Recently uploaded (20)

Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 

Serverless GraphQL for Product Developers

  • 1. Serverless GraphQL for Product Developers Take your productivity to the next level, on top of your existing backends. Sashko Stubailo, @stubailo Open Source at Apollo, apollographql.com
  • 2. Data management is more important than ever UI Data management API Backends and storage InternetNow that apps are built with APIs and thick clients, it’s not enough to just generate the right HTML per-request.
  • 3. From “How GraphQL Replaces Redux” by Mark Johnson on Medium
  • 4. Multiple platforms and services Backend Backend Backend Backend Backend iOS Android Web VR Assistant
  • 5. Loads of complexity in frontend tooling Reducers Sagas Advanced requirements Disparate tools Middleware Selectors Action creators Thunks Promises Observables Local state Server-side rendering Caching Pagination Offline Optimistic UI Error handling Realtime Mutations Loading states
  • 6. Apollo and GraphQL organize your data Backend Backend Backend Backend Backend iOS Android Web VR Assistant
  • 7. Simplify frontend code Reducers Sagas Middleware Selectors Action creators Thunks Promises Observables Local state Server-side rendering Caching Pagination Offline Optimistic UI Error handling Realtime Mutations Loading states const GET_DOGS = gql` query { dogs { id breed displayImage } } `; const Feed = () => ( <Query query={GET_DOGS}> {({ loading, error, data }) => { if (loading) return <Fetching />; if (error) return <Error />; return <DogList data={data.dogs} />; }} </Query> );
  • 8. From “Reducing our Redux code with React Apollo” by Peggy Rayzis on Medium
  • 9. How does GraphQL provide these benefits? 1. Schema describes available data 2. Queries describe requirements 3. Tools improve productivity type Dog { id: String! breed: String! displayImage: String images: [Image] subbreeds: [String] } query { dogs { id breed displayImage } } <Query query={X}> ({ data, error, loading }) => { ... } </Query>
  • 10. OK, so how do we get this in real life?
  • 11. Put GraphQL over your existing APIs Continue to use your existing backends Don’t re-implement business logic or permissions rules Make the translation layer as thin as possible, so it doesn’t become a bottleneck Diagram from Medium’s blog post:
  • 12. GraphQL is a client-focused API We’ve seen teams have the most success when the API directly serves the needs of the frontend Empower frontend developers to add fields as needed Implement your GraphQL API in JavaScript This means we need the GraphQL API to be simple and fast to develop...
  • 13. Apollo Server 2.0 ➔ Dramatically simpler API ➔ Production optimizations built in ➔ Runs everywhere with the same code
  • 14. Let’s implement GraphQL over REST for puppy photos
  • 15. Define the schemaUse the concise and readable GraphQL schema language const typeDefs = gql` type Query { dogs: [Dog] dog(breed: String!): Dog } type Dog { id: String! breed: String! displayImage: String images: [Image] subbreeds: [String] } type Image { url: String! id: String! } `;
  • 16. Define a REST data source Caching and deduplication of the API is handled for you class DogAPI extends RESTDataSource { baseURL = "https://dog.ceo/api"; async getDogs() { const dogs = await this.get(`breeds/list/all`); return _.map(dogs, createDog); } async getDisplayImage(breed) { return this.get(`breed/${breed}/images/random`); } // ... }
  • 17. Write resolvers Map data source methods to the schema const resolvers = { Query: { dogs: async (root, args, { dataSources }) => { return dataSources.dogAPI.getDogs(); }, dog: async (root, { breed }, { dataSources }) => { return dataSources.dogAPI.getDog(breed); } }, Dog: { displayImage: async ({ breed }, args, { dataSources }) => { return dataSources.dogAPI.getDisplayImage(breed); }, images: async ({ breed }, args, { dataSources }) => { return dataSources.dogAPI.getImages(breed); } } };
  • 18. Put them together Now you’ve got a production-ready GraphQL API const server = new ApolloServer({ typeDefs, resolvers, dataSources: () => ({ dogAPI: new DogAPI() }) });
  • 20. OK, so where do we deploy this layer? Since we want to think of this as a thin translation layer that makes our development more productive, we don’t want to worry about managing and scaling servers or containers…
  • 21. Serverless is a perfect fit for GraphQL APIs! Apollo Server runs on every serverless provider: ➔ Lambda ➔ Azure Functions ➔ Google Cloud UI Apollo Client Backends and storage Serverless ApolloServer
  • 22. Deploying UI and functions on Netlify UI code API code CDN AWS Lambda
  • 24. Reducing friction in API deployment Netlify has made it not just easy to deploy the API, but part of the same workflow as frontend code Deploy previews you’re used to for frontend code for the API as well Over time, I hope there are more options that make API deployment accessible to product developers
  • 25. What about monitoring? You don’t want to just get performance reports for a single endpoint. You want to see the data in terms of how you implemented the schema. The fine-grained nature of GraphQL enables you to see detailed information about how your API is doing.
  • 26. Apollo Engine: Tooling for GraphQL ➔ Monitor GraphQL resolvers for usage statistics, performance, and errors ➔ Track schema changes over time ➔ Integrate into Slack, GitHub, Datadog, and more
  • 27. Keep track of your schema
  • 29. Demo: Opening a PR with a change Deploying a new change is so easy, we’re gonna do it right now! We’ll look for: ➔ Netlify deploy preview for frontend and backend ➔ Engine schema check and diff
  • 30. What about caching? The best option is to cache the underlying REST calls, since those are already set up to work with caching. Serverless architectures don’t make it easy to persist data across requests, but we’ve got an answer!
  • 31. Data Sources ➔ Modular pattern for accessing REST from GraphQL ➔ Built-in deduplication and data pipeline ➔ Caching built in with support for Redis and Memcached
  • 32. Remember our data source? class DogAPI extends RESTDataSource { baseURL = "https://dog.ceo/api"; async getDogs() { const dogs = await this.get(`breeds/list/all`); return _.map(dogs, createDog); } async getDisplayImage(breed) { return this.get(`breed/${breed}/images/random`); } // ... }
  • 33. Caching backend requests with serverless Apollo Server data sources integrate with Redis, and you can use any cloud provider Reduce backend API requests and speed up response times UI Apollo Client Backends and storage Serverless ApolloServer Redis provider
  • 34. Zooming out: Super productive development Frontend React for UI, Apollo for state management, Netlify to deploy API Apollo Server 2.0 for GraphQL, Lambda with Netlify functions for deployment, and Data Sources + Redis for caching Tooling Apollo Engine for performance tracing and schema versioning
  • 35. Improving your API and data management will dramatically increase velocity. Key premise:
  • 36. Reaching for the ideal developer experience React, Apollo, and serverless technologies are coming together into a simple and modern set of tools for: ➔ Data management ➔ API development ➔ API performance ➔ Deployment ➔ PR checks and previews ➔ Version tracking ➔ Performance tracking What’s next? Two things...
  • 37. They say JavaScript can run anywhere... ➔ Browser ➔ Mobile ➔ Server ➔ Cloud functions ➔ Google spreadsheets And it turns out, now also inside CDNs!
  • 38. Apollo Server on the edge Bring your API and cache right to your users apollographql.com/edge UI Apollo Client Backends and storage CloudFlare workers in 151 data centers CDN cache UI Apollo Client
  • 39. Next: Schema-based tooling ➔ The GraphQL schema describes the data available ➔ Engine keeps track of changes ➔ How can we use all this info to help you write your code?
  • 40. Coming soon: Apollo for Visual Studio Code
  • 41. Run queries and even realtime subscriptions
  • 42. Get performance stats from your API as you type
  • 43. A really productive API experience
  • 44. We’re making using and developing APIs fun and productive. And serverless is going to be a big part of that. github.com/apollographql • apollographql.com • @apollographql