SlideShare a Scribd company logo
1 of 28
Download to read offline
Adding GraphQL to
your Existing Architecture
Sashko Stubailo
Open Source Lead, Apollo
@stubailo
• Client-side developer ergonomics
• Flexibility means fewer API changes
• Better efficiency, fetch just what you need
GraphQL makes everyone’s life better
So what might block people from using it?
• Where do I start?
• Can I use this at work without rewriting my
existing stuff?
• How do I get running in production?
First questions people ask
• Sometimes presented as totally new way of thinking,
which makes it seem like a big investment
• In practice, it’s a standardization of things people were
already doing
Is GraphQL really that different?
SIDE NOTE
• It’s what made React so easy to adopt
• Can you use it for just one feature or component?
• GraphQL can be done the same way
The golden ticket: Incremental adoption
Web App
Elastic Search MongoDB Dynamo DB
C L I E N T
S E R V E R
API Server
Existing app
Web App
Elastic Search MongoDB Dynamo DB
C L I E N T
S E R V E R
API Server
Existing app + GraphQL
?
?
• Fetch GraphQL anywhere you can do an HTTP request
• For fancier features—caching, network state
management, mutation handling—we’ve worked hard to
make Apollo Client compatible everywhere
• For some projects, great opportunity to improve your UI
and data management together
On the client, incremental is easy
• Model virtually any kind of application data
• Start with client-side needs, fill in API bit by bit
• Uniquely suited to being an API gateway, calling
your existing backends
• Suggestion: Experiment with clients that you can
push code to easily, like web or React Native
Incrementally adoptable API?
Two ways to present GraphQL
• Brownfield, existing app with existing
backend, every situation is different
• GraphQL addresses critical problems
• Greenfield, new app with new
backend, easy to write tutorials
• GraphQL sets you up to grow
• Most content builds “hello world” style APIs from
scratch, or starts with existing GraphQL API
• After you get a taste of the GraphQL experience, you
need a way to get it running in your existing app
• Everyone’s situation is unique
• Can we cut the problem into small bits?
Problem: Not enough guidance
Share live examples of GraphQL server patterns
Launchpad
• Mocking: launchpad.graphql.com/98lq7vz8r
• Neo4j: launchpad.graphql.com/3wzp7qnjv
• MongoDB: launchpad.graphql.com/vkmr1kl83
• Share your own patterns—DataLoader, pagination, etc
—at apollographql/awesome-launchpad
Existing samples on Launchpad
GROW
GRAPHQL COMMUNITY
Getting ready for
production
THE NEXT STEP
1. Understand what is going on inside your server
with instrumentation
2. Know the tools available to make improvements
3. Ensure that backend services are not adversely
affected by the new API layer
Production learning checklist
• You need your instrumentation to understand GraphQL
• Need to have some way to identify common queries,
expensive fields, critical paths, and schema usage
• Write your client code and queries in a way that lets you
identify what you see on the server
First: Instrumentation
Two classes of problems
• High latency or bandwidth usage causes bad experience
for the end-user client app
• Inefficient execution or expensive requests result in too
much load on the API or backend
Client-side improvements
• Load data judiciously to avoid
performance issues
• Load less data at a time, split into
multiple queries, avoid expensive fields
• Improve client-side caching with an
offline cache, cache redirects, and
optimistic UI
• Otherwise, need to improve server
query Human {
human {
name
weather
friends {
name
}
}
}
query Human
Biggest question: Server performance
• Executing each query with low latency needs to be
balanced with load on the API server and backends
• Two dimensions that can be optimized: GraphQL server
overhead, and work done by backend APIs and databases
GraphQL server overhead?
• GraphQL execution engine itself is quite efficient for the value it
provides, usually not the main thing to optimize
• Caching parsing and validation helps a lot, those are some of the
most expensive steps
• Make it stateless to scale horizontally
• Break out of GraphQL data model if necessary with custom scalars
• In general, overhead is easy to limit
Backend API usage
• GraphQL API is much closer to the backend, so
same number of roundtrips is less time
• We should try to make sure we do the same
number of fetches or less than we were doing
without GraphQL
• How can we reduce fetches to the backend or
make them more efficient?
REST
Reducing backend load
• Leverage backend features when you can
• Use something like DataLoader to collect requirements,
then make one batched request and avoid extra roundtrips
• Make sure GraphQL server manages backend load by
listening to backpressure or rate limiting calls
• In theory GraphQL can be very efficient since all data needs
are known ahead of time
Persisted queries?
• Save queries to a database and only send the ID instead
of the whole query string
• Supported by Apollo Client and Relay Modern
• Important to distinguish several possible concepts:
• Static queries - no runtime modification of queries
• Whitelisted queries - only accept known queries
• Persisted queries - send query ID, look it up on server
• Compiled queries - do some optimization in build step
• Different potential benefits from each one
{
id: ‘23235’,
variables: …
}
Preventing malicious queries
• Simple: Basic rate limiting
• Medium: Statically calculate cost from the query
document before execution, reject if too high
• Advanced: Track cost of each client over time, to block
people loading too much data quickly
• For extreme cases: Explicit whitelisting
Advanced performance ideas
• Get the same performance as a hand-crafted REST endpoint
but with no loss of generality
• For certain applications that have extremely common
queries, hand-optimize queries or fragments
• In the resolver, check if we are looking for that selection set
and run a more efficient batched fetch for the subtree
• HTTP caching of whole query results
• You can incrementally adopt GraphQL, start with a quick
prototype to get a feel for it
• Instrument everything to avoid unnecessary optimizations
• Work with backend devs to make sure the databases and
services are happy
• The normal thing is usually fine, but if you discover issues
there are many paths to optimize your GraphQL API
Conclusions
Help grow the community!
• Write more content about intermediate GraphQL topics,
to help people get this amazing API with their data
• Write about your production experiences, performance
optimizations you’ve made, and new patterns you come
up with
Tweet or DM me, let’s work together: @stubailo

More Related Content

What's hot

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 toolsSashko Stubailo
 
Into to GraphQL
Into to GraphQLInto to GraphQL
Into to GraphQLshobot
 
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 GraphQLVinci Rufus
 
Graphql presentation
Graphql presentationGraphql presentation
Graphql presentationVibhor Grover
 
GraphQL Introduction
GraphQL IntroductionGraphQL Introduction
GraphQL IntroductionSerge Huber
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQLRodrigo Prates
 
How to GraphQL
How to GraphQLHow to GraphQL
How to GraphQLTomasz Bak
 
An intro to GraphQL
An intro to GraphQLAn intro to GraphQL
An intro to GraphQLvaluebound
 
How to GraphQL: React Apollo
How to GraphQL: React ApolloHow to GraphQL: React Apollo
How to GraphQL: React ApolloTomasz Bak
 
Better APIs with GraphQL
Better APIs with GraphQL Better APIs with GraphQL
Better APIs with GraphQL Josh Price
 
REST vs GraphQL
REST vs GraphQLREST vs GraphQL
REST vs GraphQLSquareboat
 
Serverless GraphQL for Product Developers
Serverless GraphQL for Product DevelopersServerless GraphQL for Product Developers
Serverless GraphQL for Product DevelopersSashko Stubailo
 
GraphQL With Relay Part Deux
GraphQL With Relay Part DeuxGraphQL With Relay Part Deux
GraphQL With Relay Part DeuxBrad Pillow
 
Introduction to graphQL
Introduction to graphQLIntroduction to graphQL
Introduction to graphQLMuhilvarnan V
 

What's hot (20)

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
 
GraphQL + relay
GraphQL + relayGraphQL + relay
GraphQL + relay
 
Into to GraphQL
Into to GraphQLInto to GraphQL
Into to GraphQL
 
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 Introduction
GraphQL IntroductionGraphQL Introduction
GraphQL Introduction
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
How to GraphQL
How to GraphQLHow to GraphQL
How to GraphQL
 
An intro to GraphQL
An intro to GraphQLAn intro to GraphQL
An intro to GraphQL
 
GraphQL & Relay
GraphQL & RelayGraphQL & Relay
GraphQL & Relay
 
GraphQL
GraphQLGraphQL
GraphQL
 
Graphql
GraphqlGraphql
Graphql
 
How to GraphQL: React Apollo
How to GraphQL: React ApolloHow to GraphQL: React Apollo
How to GraphQL: React Apollo
 
Better APIs with GraphQL
Better APIs with GraphQL Better APIs with GraphQL
Better APIs with GraphQL
 
REST vs GraphQL
REST vs GraphQLREST vs GraphQL
REST vs GraphQL
 
Serverless GraphQL for Product Developers
Serverless GraphQL for Product DevelopersServerless GraphQL for Product Developers
Serverless GraphQL for Product Developers
 
Intro to GraphQL
 Intro to GraphQL Intro to GraphQL
Intro to GraphQL
 
GraphQL With Relay Part Deux
GraphQL With Relay Part DeuxGraphQL With Relay Part Deux
GraphQL With Relay Part Deux
 
Introduction to graphQL
Introduction to graphQLIntroduction to graphQL
Introduction to graphQL
 

Similar to Adding GraphQL to your existing architecture

CONDG April 23 2020 - Baskar Rao - GraphQL
CONDG April 23 2020 - Baskar Rao - GraphQLCONDG April 23 2020 - Baskar Rao - GraphQL
CONDG April 23 2020 - Baskar Rao - GraphQLMatthew Groves
 
Introduction to Testing GraphQL Presentation
Introduction to Testing GraphQL PresentationIntroduction to Testing GraphQL Presentation
Introduction to Testing GraphQL PresentationKnoldus Inc.
 
apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...
apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...
apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...apidays
 
GraphQL-ify your APIs - Devoxx UK 2021
 GraphQL-ify your APIs - Devoxx UK 2021 GraphQL-ify your APIs - Devoxx UK 2021
GraphQL-ify your APIs - Devoxx UK 2021Soham Dasgupta
 
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 togetherReact Conf Brasil
 
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)Hafiz Ismail
 
Active Cloud DB at CloudComp '10
Active Cloud DB at CloudComp '10Active Cloud DB at CloudComp '10
Active Cloud DB at CloudComp '10Chris Bunch
 
Gutenberg and Headless WordPress.pdf
Gutenberg and Headless WordPress.pdfGutenberg and Headless WordPress.pdf
Gutenberg and Headless WordPress.pdfWP Engine
 
Advantages of Rails Framework
Advantages of Rails FrameworkAdvantages of Rails Framework
Advantages of Rails FrameworkSathish Mariappan
 
GraphQL Munich Meetup #1 - How We Use GraphQL At Commercetools
GraphQL Munich Meetup #1 - How We Use GraphQL At CommercetoolsGraphQL Munich Meetup #1 - How We Use GraphQL At Commercetools
GraphQL Munich Meetup #1 - How We Use GraphQL At CommercetoolsNicola Molinari
 
Running Airflow Workflows as ETL Processes on Hadoop
Running Airflow Workflows as ETL Processes on HadoopRunning Airflow Workflows as ETL Processes on Hadoop
Running Airflow Workflows as ETL Processes on Hadoopclairvoyantllc
 
Lessons learned on the Azure API Stewardship Journey.pptx
Lessons learned on the Azure API Stewardship Journey.pptxLessons learned on the Azure API Stewardship Journey.pptx
Lessons learned on the Azure API Stewardship Journey.pptxapidays
 
SOA with Zend Framework
SOA with Zend FrameworkSOA with Zend Framework
SOA with Zend FrameworkMike Willbanks
 
Your API on Steroids
Your API on Steroids Your API on Steroids
Your API on Steroids QAware GmbH
 
Untangling spring week11
Untangling spring week11Untangling spring week11
Untangling spring week11Derek Jacoby
 
Performance tuning Grails applications
Performance tuning Grails applicationsPerformance tuning Grails applications
Performance tuning Grails applicationsLari Hotari
 
API Management for GraphQL
API Management for GraphQLAPI Management for GraphQL
API Management for GraphQLWSO2
 
The Fifth Elephant 2016: Self-Serve Performance Tuning for Hadoop and Spark
The Fifth Elephant 2016: Self-Serve Performance Tuning for Hadoop and SparkThe Fifth Elephant 2016: Self-Serve Performance Tuning for Hadoop and Spark
The Fifth Elephant 2016: Self-Serve Performance Tuning for Hadoop and SparkAkshay Rai
 

Similar to Adding GraphQL to your existing architecture (20)

CONDG April 23 2020 - Baskar Rao - GraphQL
CONDG April 23 2020 - Baskar Rao - GraphQLCONDG April 23 2020 - Baskar Rao - GraphQL
CONDG April 23 2020 - Baskar Rao - GraphQL
 
Introduction to Testing GraphQL Presentation
Introduction to Testing GraphQL PresentationIntroduction to Testing GraphQL Presentation
Introduction to Testing GraphQL Presentation
 
apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...
apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...
apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...
 
GraphQL.net
GraphQL.netGraphQL.net
GraphQL.net
 
GraphQL-ify your APIs - Devoxx UK 2021
 GraphQL-ify your APIs - Devoxx UK 2021 GraphQL-ify your APIs - Devoxx UK 2021
GraphQL-ify your APIs - Devoxx UK 2021
 
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
 
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
 
Active Cloud DB at CloudComp '10
Active Cloud DB at CloudComp '10Active Cloud DB at CloudComp '10
Active Cloud DB at CloudComp '10
 
Gutenberg and Headless WordPress.pdf
Gutenberg and Headless WordPress.pdfGutenberg and Headless WordPress.pdf
Gutenberg and Headless WordPress.pdf
 
Advantages of Rails Framework
Advantages of Rails FrameworkAdvantages of Rails Framework
Advantages of Rails Framework
 
GraphQL Munich Meetup #1 - How We Use GraphQL At Commercetools
GraphQL Munich Meetup #1 - How We Use GraphQL At CommercetoolsGraphQL Munich Meetup #1 - How We Use GraphQL At Commercetools
GraphQL Munich Meetup #1 - How We Use GraphQL At Commercetools
 
Running Airflow Workflows as ETL Processes on Hadoop
Running Airflow Workflows as ETL Processes on HadoopRunning Airflow Workflows as ETL Processes on Hadoop
Running Airflow Workflows as ETL Processes on Hadoop
 
Key alias dev standard final
Key alias   dev standard finalKey alias   dev standard final
Key alias dev standard final
 
Lessons learned on the Azure API Stewardship Journey.pptx
Lessons learned on the Azure API Stewardship Journey.pptxLessons learned on the Azure API Stewardship Journey.pptx
Lessons learned on the Azure API Stewardship Journey.pptx
 
SOA with Zend Framework
SOA with Zend FrameworkSOA with Zend Framework
SOA with Zend Framework
 
Your API on Steroids
Your API on Steroids Your API on Steroids
Your API on Steroids
 
Untangling spring week11
Untangling spring week11Untangling spring week11
Untangling spring week11
 
Performance tuning Grails applications
Performance tuning Grails applicationsPerformance tuning Grails applications
Performance tuning Grails applications
 
API Management for GraphQL
API Management for GraphQLAPI Management for GraphQL
API Management for GraphQL
 
The Fifth Elephant 2016: Self-Serve Performance Tuning for Hadoop and Spark
The Fifth Elephant 2016: Self-Serve Performance Tuning for Hadoop and SparkThe Fifth Elephant 2016: Self-Serve Performance Tuning for Hadoop and Spark
The Fifth Elephant 2016: Self-Serve Performance Tuning for Hadoop and Spark
 

Recently uploaded

Extra-120324-Visite-Entreprise-icare.pdf
Extra-120324-Visite-Entreprise-icare.pdfExtra-120324-Visite-Entreprise-icare.pdf
Extra-120324-Visite-Entreprise-icare.pdfInfopole1
 
The New Cloud World Order Is FinOps (Slideshow)
The New Cloud World Order Is FinOps (Slideshow)The New Cloud World Order Is FinOps (Slideshow)
The New Cloud World Order Is FinOps (Slideshow)codyslingerland1
 
March Patch Tuesday
March Patch TuesdayMarch Patch Tuesday
March Patch TuesdayIvanti
 
Keep Your Finger on the Pulse of Your Building's Performance with IES Live
Keep Your Finger on the Pulse of Your Building's Performance with IES LiveKeep Your Finger on the Pulse of Your Building's Performance with IES Live
Keep Your Finger on the Pulse of Your Building's Performance with IES LiveIES VE
 
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.pdfCheryl Hung
 
IT Service Management (ITSM) Best Practices for Advanced Computing
IT Service Management (ITSM) Best Practices for Advanced ComputingIT Service Management (ITSM) Best Practices for Advanced Computing
IT Service Management (ITSM) Best Practices for Advanced ComputingMAGNIntelligence
 
Technical SEO for Improved Accessibility WTS FEST
Technical SEO for Improved Accessibility  WTS FESTTechnical SEO for Improved Accessibility  WTS FEST
Technical SEO for Improved Accessibility WTS FESTBillieHyde
 
UiPath Studio Web workshop series - Day 1
UiPath Studio Web workshop series  - Day 1UiPath Studio Web workshop series  - Day 1
UiPath Studio Web workshop series - Day 1DianaGray10
 
Patch notes explaining DISARM Version 1.4 update
Patch notes explaining DISARM Version 1.4 updatePatch notes explaining DISARM Version 1.4 update
Patch notes explaining DISARM Version 1.4 updateadam112203
 
2024.03.12 Cost drivers of cultivated meat production.pdf
2024.03.12 Cost drivers of cultivated meat production.pdf2024.03.12 Cost drivers of cultivated meat production.pdf
2024.03.12 Cost drivers of cultivated meat production.pdfThe Good Food Institute
 
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedInOutage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedInThousandEyes
 
From the origin to the future of Open Source model and business
From the origin to the future of  Open Source model and businessFrom the origin to the future of  Open Source model and business
From the origin to the future of Open Source model and businessFrancesco Corti
 
Explore the UiPath Community and ways you can benefit on your journey to auto...
Explore the UiPath Community and ways you can benefit on your journey to auto...Explore the UiPath Community and ways you can benefit on your journey to auto...
Explore the UiPath Community and ways you can benefit on your journey to auto...DianaGray10
 
Top 10 Squarespace Development Companies
Top 10 Squarespace Development CompaniesTop 10 Squarespace Development Companies
Top 10 Squarespace Development CompaniesTopCSSGallery
 
Scenario Library et REX Discover industry- and role- based scenarios
Scenario Library et REX Discover industry- and role- based scenariosScenario Library et REX Discover industry- and role- based scenarios
Scenario Library et REX Discover industry- and role- based scenariosErol GIRAUDY
 
UiPath Studio Web workshop Series - Day 3
UiPath Studio Web workshop Series - Day 3UiPath Studio Web workshop Series - Day 3
UiPath Studio Web workshop Series - Day 3DianaGray10
 
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptxGraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptxNeo4j
 
Planetek Italia Srl - Corporate Profile Brochure
Planetek Italia Srl - Corporate Profile BrochurePlanetek Italia Srl - Corporate Profile Brochure
Planetek Italia Srl - Corporate Profile BrochurePlanetek Italia Srl
 
Introduction - IPLOOK NETWORKS CO., LTD.
Introduction - IPLOOK NETWORKS CO., LTD.Introduction - IPLOOK NETWORKS CO., LTD.
Introduction - IPLOOK NETWORKS CO., LTD.IPLOOK Networks
 
UiPath Studio Web workshop series - Day 2
UiPath Studio Web workshop series - Day 2UiPath Studio Web workshop series - Day 2
UiPath Studio Web workshop series - Day 2DianaGray10
 

Recently uploaded (20)

Extra-120324-Visite-Entreprise-icare.pdf
Extra-120324-Visite-Entreprise-icare.pdfExtra-120324-Visite-Entreprise-icare.pdf
Extra-120324-Visite-Entreprise-icare.pdf
 
The New Cloud World Order Is FinOps (Slideshow)
The New Cloud World Order Is FinOps (Slideshow)The New Cloud World Order Is FinOps (Slideshow)
The New Cloud World Order Is FinOps (Slideshow)
 
March Patch Tuesday
March Patch TuesdayMarch Patch Tuesday
March Patch Tuesday
 
Keep Your Finger on the Pulse of Your Building's Performance with IES Live
Keep Your Finger on the Pulse of Your Building's Performance with IES LiveKeep Your Finger on the Pulse of Your Building's Performance with IES Live
Keep Your Finger on the Pulse of Your Building's Performance with IES Live
 
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
 
IT Service Management (ITSM) Best Practices for Advanced Computing
IT Service Management (ITSM) Best Practices for Advanced ComputingIT Service Management (ITSM) Best Practices for Advanced Computing
IT Service Management (ITSM) Best Practices for Advanced Computing
 
Technical SEO for Improved Accessibility WTS FEST
Technical SEO for Improved Accessibility  WTS FESTTechnical SEO for Improved Accessibility  WTS FEST
Technical SEO for Improved Accessibility WTS FEST
 
UiPath Studio Web workshop series - Day 1
UiPath Studio Web workshop series  - Day 1UiPath Studio Web workshop series  - Day 1
UiPath Studio Web workshop series - Day 1
 
Patch notes explaining DISARM Version 1.4 update
Patch notes explaining DISARM Version 1.4 updatePatch notes explaining DISARM Version 1.4 update
Patch notes explaining DISARM Version 1.4 update
 
2024.03.12 Cost drivers of cultivated meat production.pdf
2024.03.12 Cost drivers of cultivated meat production.pdf2024.03.12 Cost drivers of cultivated meat production.pdf
2024.03.12 Cost drivers of cultivated meat production.pdf
 
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedInOutage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
 
From the origin to the future of Open Source model and business
From the origin to the future of  Open Source model and businessFrom the origin to the future of  Open Source model and business
From the origin to the future of Open Source model and business
 
Explore the UiPath Community and ways you can benefit on your journey to auto...
Explore the UiPath Community and ways you can benefit on your journey to auto...Explore the UiPath Community and ways you can benefit on your journey to auto...
Explore the UiPath Community and ways you can benefit on your journey to auto...
 
Top 10 Squarespace Development Companies
Top 10 Squarespace Development CompaniesTop 10 Squarespace Development Companies
Top 10 Squarespace Development Companies
 
Scenario Library et REX Discover industry- and role- based scenarios
Scenario Library et REX Discover industry- and role- based scenariosScenario Library et REX Discover industry- and role- based scenarios
Scenario Library et REX Discover industry- and role- based scenarios
 
UiPath Studio Web workshop Series - Day 3
UiPath Studio Web workshop Series - Day 3UiPath Studio Web workshop Series - Day 3
UiPath Studio Web workshop Series - Day 3
 
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptxGraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
 
Planetek Italia Srl - Corporate Profile Brochure
Planetek Italia Srl - Corporate Profile BrochurePlanetek Italia Srl - Corporate Profile Brochure
Planetek Italia Srl - Corporate Profile Brochure
 
Introduction - IPLOOK NETWORKS CO., LTD.
Introduction - IPLOOK NETWORKS CO., LTD.Introduction - IPLOOK NETWORKS CO., LTD.
Introduction - IPLOOK NETWORKS CO., LTD.
 
UiPath Studio Web workshop series - Day 2
UiPath Studio Web workshop series - Day 2UiPath Studio Web workshop series - Day 2
UiPath Studio Web workshop series - Day 2
 

Adding GraphQL to your existing architecture

  • 1. Adding GraphQL to your Existing Architecture Sashko Stubailo Open Source Lead, Apollo @stubailo
  • 2. • Client-side developer ergonomics • Flexibility means fewer API changes • Better efficiency, fetch just what you need GraphQL makes everyone’s life better So what might block people from using it?
  • 3. • Where do I start? • Can I use this at work without rewriting my existing stuff? • How do I get running in production? First questions people ask
  • 4. • Sometimes presented as totally new way of thinking, which makes it seem like a big investment • In practice, it’s a standardization of things people were already doing Is GraphQL really that different? SIDE NOTE
  • 5. • It’s what made React so easy to adopt • Can you use it for just one feature or component? • GraphQL can be done the same way The golden ticket: Incremental adoption
  • 6. Web App Elastic Search MongoDB Dynamo DB C L I E N T S E R V E R API Server Existing app
  • 7. Web App Elastic Search MongoDB Dynamo DB C L I E N T S E R V E R API Server Existing app + GraphQL ? ?
  • 8. • Fetch GraphQL anywhere you can do an HTTP request • For fancier features—caching, network state management, mutation handling—we’ve worked hard to make Apollo Client compatible everywhere • For some projects, great opportunity to improve your UI and data management together On the client, incremental is easy
  • 9. • Model virtually any kind of application data • Start with client-side needs, fill in API bit by bit • Uniquely suited to being an API gateway, calling your existing backends • Suggestion: Experiment with clients that you can push code to easily, like web or React Native Incrementally adoptable API?
  • 10. Two ways to present GraphQL • Brownfield, existing app with existing backend, every situation is different • GraphQL addresses critical problems • Greenfield, new app with new backend, easy to write tutorials • GraphQL sets you up to grow
  • 11. • Most content builds “hello world” style APIs from scratch, or starts with existing GraphQL API • After you get a taste of the GraphQL experience, you need a way to get it running in your existing app • Everyone’s situation is unique • Can we cut the problem into small bits? Problem: Not enough guidance
  • 12. Share live examples of GraphQL server patterns Launchpad
  • 13. • Mocking: launchpad.graphql.com/98lq7vz8r • Neo4j: launchpad.graphql.com/3wzp7qnjv • MongoDB: launchpad.graphql.com/vkmr1kl83 • Share your own patterns—DataLoader, pagination, etc —at apollographql/awesome-launchpad Existing samples on Launchpad
  • 16. 1. Understand what is going on inside your server with instrumentation 2. Know the tools available to make improvements 3. Ensure that backend services are not adversely affected by the new API layer Production learning checklist
  • 17. • You need your instrumentation to understand GraphQL • Need to have some way to identify common queries, expensive fields, critical paths, and schema usage • Write your client code and queries in a way that lets you identify what you see on the server First: Instrumentation
  • 18. Two classes of problems • High latency or bandwidth usage causes bad experience for the end-user client app • Inefficient execution or expensive requests result in too much load on the API or backend
  • 19. Client-side improvements • Load data judiciously to avoid performance issues • Load less data at a time, split into multiple queries, avoid expensive fields • Improve client-side caching with an offline cache, cache redirects, and optimistic UI • Otherwise, need to improve server query Human { human { name weather friends { name } } } query Human
  • 20. Biggest question: Server performance • Executing each query with low latency needs to be balanced with load on the API server and backends • Two dimensions that can be optimized: GraphQL server overhead, and work done by backend APIs and databases
  • 21. GraphQL server overhead? • GraphQL execution engine itself is quite efficient for the value it provides, usually not the main thing to optimize • Caching parsing and validation helps a lot, those are some of the most expensive steps • Make it stateless to scale horizontally • Break out of GraphQL data model if necessary with custom scalars • In general, overhead is easy to limit
  • 22. Backend API usage • GraphQL API is much closer to the backend, so same number of roundtrips is less time • We should try to make sure we do the same number of fetches or less than we were doing without GraphQL • How can we reduce fetches to the backend or make them more efficient? REST
  • 23. Reducing backend load • Leverage backend features when you can • Use something like DataLoader to collect requirements, then make one batched request and avoid extra roundtrips • Make sure GraphQL server manages backend load by listening to backpressure or rate limiting calls • In theory GraphQL can be very efficient since all data needs are known ahead of time
  • 24. Persisted queries? • Save queries to a database and only send the ID instead of the whole query string • Supported by Apollo Client and Relay Modern • Important to distinguish several possible concepts: • Static queries - no runtime modification of queries • Whitelisted queries - only accept known queries • Persisted queries - send query ID, look it up on server • Compiled queries - do some optimization in build step • Different potential benefits from each one { id: ‘23235’, variables: … }
  • 25. Preventing malicious queries • Simple: Basic rate limiting • Medium: Statically calculate cost from the query document before execution, reject if too high • Advanced: Track cost of each client over time, to block people loading too much data quickly • For extreme cases: Explicit whitelisting
  • 26. Advanced performance ideas • Get the same performance as a hand-crafted REST endpoint but with no loss of generality • For certain applications that have extremely common queries, hand-optimize queries or fragments • In the resolver, check if we are looking for that selection set and run a more efficient batched fetch for the subtree • HTTP caching of whole query results
  • 27. • You can incrementally adopt GraphQL, start with a quick prototype to get a feel for it • Instrument everything to avoid unnecessary optimizations • Work with backend devs to make sure the databases and services are happy • The normal thing is usually fine, but if you discover issues there are many paths to optimize your GraphQL API Conclusions
  • 28. Help grow the community! • Write more content about intermediate GraphQL topics, to help people get this amazing API with their data • Write about your production experiences, performance optimizations you’ve made, and new patterns you come up with Tweet or DM me, let’s work together: @stubailo