SlideShare a Scribd company logo
1 of 25
Download to read offline
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARECOPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
GraphQL Data Loaders
How to feed your GraphQL API with data the smart way
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
Jakub Draganek
Python Developer @ Mirumee Software
Ariadne
Saleor
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
GRAPHQL API SETUP EXAMPLE
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
Schema
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
GraphQL query execution
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
GraphQL query execution
CLIENT
QUERY
getData()
getOtherData()
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
GraphQL query
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
Building response
■ Parse
■ Validate
■ Execute
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
Resolver execution tree
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
name
kingdoms
ruler
name
house
name
KINGDOM PERSON HOUSEQUERY
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
Resolvers execution flow
■ Receive parent and arguments
■ Fetch / transform data in resolver
■ Wait until finished and iterate on children
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
Simple and elegant, what is wrong with that?
Things start to get very ugly quickly…
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
Give me more data!
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
Execution steps
■ run Query.kingdoms
■ for Kingdom run Kingdom.name and Kingdom.ruler
■ for ruler run Person.name, Person.parents, Person.house
■ for kingdom ruler’s parents run Person.name and Person.house
■ for each parent house run House.name
■ …
■ fetch House.name a few more times
■ fetch same Person a few times with everything once again!
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
N+1 and other problems
■ Repetition of the same data fetching
■ Suboptimal database usage
■ Overloaded external services
■ Data inconsistency
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
Solution?
■ Batching
■ Caching
■ Data layer abstraction
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
Data layer abstraction
QUERY
resolver
resolver
DB
Services
Data layer
abstraction
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
DataLoader
Generic data fetching layer
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
DataLoader
■ Collect keys from every .load()
■ Batch data fetch on event loop tick
■ Each .load() revolves to data
■ Cache data for a single request
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
DataLoader loop
LOOP
load(1)
load(2)
load(5)
batch([1,2,5])resolver DBCACHE
resolver
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
Async resolver flow
load(1)
load(2)
batch([1,2])
resolver 2
resolver 1
promise
promise
tick!
⌛
DB
{1: “data_1”, 2: “data_2}
resolver 1
resolve promise!
SOON...
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
What is important?
■ Asynchronous environment
■ Single instance of Data Loader per request
■ One DataLoader per GraphQL Type
■ No business logic in the data layer!
■ All data fetching in the batch function
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
Where now?
■ Data Loader implementation for your environment
■ Persistent caching
■ Different execution strategies
■ Field level query analysis
■ The sooner the better. Keep the data layer separate
COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
THANK YOU!
QUESTIONS?

More Related Content

What's hot

API Frenzy: API Strategy 101
API Frenzy: API Strategy 101API Frenzy: API Strategy 101
API Frenzy: API Strategy 101Akana
 
Building Mobile Apps with AWS Amplify
Building Mobile Apps with AWS AmplifyBuilding Mobile Apps with AWS Amplify
Building Mobile Apps with AWS AmplifyAmazon Web Services
 
The SevOne Architecture
The SevOne ArchitectureThe SevOne Architecture
The SevOne ArchitectureSevOne
 
Scaling Redis Workloads with Amazon ElastiCache - AWS Online Tech Talks
Scaling Redis Workloads with Amazon ElastiCache - AWS Online Tech TalksScaling Redis Workloads with Amazon ElastiCache - AWS Online Tech Talks
Scaling Redis Workloads with Amazon ElastiCache - AWS Online Tech TalksAmazon Web Services
 
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...luisw19
 
Containers, From Development to Production
Containers, From Development to ProductionContainers, From Development to Production
Containers, From Development to Production2nd Watch
 
Improving Performance of Micro-Frontend Applications through Error Monitoring
Improving Performance of Micro-Frontend Applications through Error MonitoringImproving Performance of Micro-Frontend Applications through Error Monitoring
Improving Performance of Micro-Frontend Applications through Error MonitoringScyllaDB
 
Introduction to Serverless
Introduction to ServerlessIntroduction to Serverless
Introduction to ServerlessNikolaus Graf
 
GraphQL Introduction
GraphQL IntroductionGraphQL Introduction
GraphQL IntroductionSerge Huber
 
Microservices
MicroservicesMicroservices
MicroservicesSmartBear
 
When Kafka Meets the Scaling and Reliability needs of World's Largest Retaile...
When Kafka Meets the Scaling and Reliability needs of World's Largest Retaile...When Kafka Meets the Scaling and Reliability needs of World's Largest Retaile...
When Kafka Meets the Scaling and Reliability needs of World's Largest Retaile...confluent
 
Getting Started with Serverless Architectures with Microservices_AWSPSSummit_...
Getting Started with Serverless Architectures with Microservices_AWSPSSummit_...Getting Started with Serverless Architectures with Microservices_AWSPSSummit_...
Getting Started with Serverless Architectures with Microservices_AWSPSSummit_...Amazon Web Services
 
Infrastructure as Code: AWS Best Practices (DEV411-R3) - AWS re:Invent 2018
Infrastructure as Code: AWS Best Practices (DEV411-R3) - AWS re:Invent 2018Infrastructure as Code: AWS Best Practices (DEV411-R3) - AWS re:Invent 2018
Infrastructure as Code: AWS Best Practices (DEV411-R3) - AWS re:Invent 2018Amazon Web Services
 
Integrating Apache Kafka Into Your Environment
Integrating Apache Kafka Into Your EnvironmentIntegrating Apache Kafka Into Your Environment
Integrating Apache Kafka Into Your Environmentconfluent
 
Building Modern APIs with GraphQL
Building Modern APIs with GraphQLBuilding Modern APIs with GraphQL
Building Modern APIs with GraphQLAmazon Web Services
 
INTERFACE by apidays 2023 - The Swiss Cheese Model of Layered API Security, L...
INTERFACE by apidays 2023 - The Swiss Cheese Model of Layered API Security, L...INTERFACE by apidays 2023 - The Swiss Cheese Model of Layered API Security, L...
INTERFACE by apidays 2023 - The Swiss Cheese Model of Layered API Security, L...apidays
 

What's hot (20)

API Frenzy: API Strategy 101
API Frenzy: API Strategy 101API Frenzy: API Strategy 101
API Frenzy: API Strategy 101
 
Building Mobile Apps with AWS Amplify
Building Mobile Apps with AWS AmplifyBuilding Mobile Apps with AWS Amplify
Building Mobile Apps with AWS Amplify
 
The SevOne Architecture
The SevOne ArchitectureThe SevOne Architecture
The SevOne Architecture
 
Intro to GraphQL
 Intro to GraphQL Intro to GraphQL
Intro to GraphQL
 
Scaling Redis Workloads with Amazon ElastiCache - AWS Online Tech Talks
Scaling Redis Workloads with Amazon ElastiCache - AWS Online Tech TalksScaling Redis Workloads with Amazon ElastiCache - AWS Online Tech Talks
Scaling Redis Workloads with Amazon ElastiCache - AWS Online Tech Talks
 
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
 
Zuul @ Netflix SpringOne Platform
Zuul @ Netflix SpringOne PlatformZuul @ Netflix SpringOne Platform
Zuul @ Netflix SpringOne Platform
 
Containers, From Development to Production
Containers, From Development to ProductionContainers, From Development to Production
Containers, From Development to Production
 
Improving Performance of Micro-Frontend Applications through Error Monitoring
Improving Performance of Micro-Frontend Applications through Error MonitoringImproving Performance of Micro-Frontend Applications through Error Monitoring
Improving Performance of Micro-Frontend Applications through Error Monitoring
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
Introduction to Serverless
Introduction to ServerlessIntroduction to Serverless
Introduction to Serverless
 
GraphQL Introduction
GraphQL IntroductionGraphQL Introduction
GraphQL Introduction
 
Microservices
MicroservicesMicroservices
Microservices
 
When Kafka Meets the Scaling and Reliability needs of World's Largest Retaile...
When Kafka Meets the Scaling and Reliability needs of World's Largest Retaile...When Kafka Meets the Scaling and Reliability needs of World's Largest Retaile...
When Kafka Meets the Scaling and Reliability needs of World's Largest Retaile...
 
Getting Started with Serverless Architectures with Microservices_AWSPSSummit_...
Getting Started with Serverless Architectures with Microservices_AWSPSSummit_...Getting Started with Serverless Architectures with Microservices_AWSPSSummit_...
Getting Started with Serverless Architectures with Microservices_AWSPSSummit_...
 
Infrastructure as Code: AWS Best Practices (DEV411-R3) - AWS re:Invent 2018
Infrastructure as Code: AWS Best Practices (DEV411-R3) - AWS re:Invent 2018Infrastructure as Code: AWS Best Practices (DEV411-R3) - AWS re:Invent 2018
Infrastructure as Code: AWS Best Practices (DEV411-R3) - AWS re:Invent 2018
 
Integrating Apache Kafka Into Your Environment
Integrating Apache Kafka Into Your EnvironmentIntegrating Apache Kafka Into Your Environment
Integrating Apache Kafka Into Your Environment
 
Building Modern APIs with GraphQL
Building Modern APIs with GraphQLBuilding Modern APIs with GraphQL
Building Modern APIs with GraphQL
 
INTERFACE by apidays 2023 - The Swiss Cheese Model of Layered API Security, L...
INTERFACE by apidays 2023 - The Swiss Cheese Model of Layered API Security, L...INTERFACE by apidays 2023 - The Swiss Cheese Model of Layered API Security, L...
INTERFACE by apidays 2023 - The Swiss Cheese Model of Layered API Security, L...
 

Similar to GraphQL Data Loaders - How to feed your GraphQL API with data the smart way

Why you should migrate to GraphQL in 2019
Why you should migrate to GraphQL in 2019Why you should migrate to GraphQL in 2019
Why you should migrate to GraphQL in 2019Mirumee Software
 
APIdays Paris 2019 - Real World Graphene: Lessons Learned from Building a Gra...
APIdays Paris 2019 - Real World Graphene: Lessons Learned from Building a Gra...APIdays Paris 2019 - Real World Graphene: Lessons Learned from Building a Gra...
APIdays Paris 2019 - Real World Graphene: Lessons Learned from Building a Gra...apidays
 
Schema-first vs. Code-first approach in GraphQL API development
Schema-first vs. Code-first approach in GraphQL API developmentSchema-first vs. Code-first approach in GraphQL API development
Schema-first vs. Code-first approach in GraphQL API developmentMirumee Software
 
Ariadne: familiar GraphQL in Python
Ariadne: familiar GraphQL in PythonAriadne: familiar GraphQL in Python
Ariadne: familiar GraphQL in PythonMirumee Software
 
Continuous Data Replication into Cloud Storage with Oracle GoldenGate
Continuous Data Replication into Cloud Storage with Oracle GoldenGateContinuous Data Replication into Cloud Storage with Oracle GoldenGate
Continuous Data Replication into Cloud Storage with Oracle GoldenGateMichael Rainey
 
Brian Bulkowski : what startups can learn from real-time bidding
Brian Bulkowski : what startups can learn from real-time biddingBrian Bulkowski : what startups can learn from real-time bidding
Brian Bulkowski : what startups can learn from real-time biddingAerospike
 
OSDC 2019 | RTO & RPO – Best Practices in Hybrid Architectures by Fernando Honig
OSDC 2019 | RTO & RPO – Best Practices in Hybrid Architectures by Fernando HonigOSDC 2019 | RTO & RPO – Best Practices in Hybrid Architectures by Fernando Honig
OSDC 2019 | RTO & RPO – Best Practices in Hybrid Architectures by Fernando HonigNETWAYS
 
Data Warehouse - Incremental Migration to the Cloud
Data Warehouse - Incremental Migration to the CloudData Warehouse - Incremental Migration to the Cloud
Data Warehouse - Incremental Migration to the CloudMichael Rainey
 
Lessons From Officeworks on Optimising Persistent Storage on AWS (Sponsored b...
Lessons From Officeworks on Optimising Persistent Storage on AWS (Sponsored b...Lessons From Officeworks on Optimising Persistent Storage on AWS (Sponsored b...
Lessons From Officeworks on Optimising Persistent Storage on AWS (Sponsored b...Amazon Web Services
 
Application and database migration workshop
Application and database migration workshopApplication and database migration workshop
Application and database migration workshopReham Maher El-Safarini
 
Make your PySpark Data Fly with Arrow!
Make your PySpark Data Fly with Arrow!Make your PySpark Data Fly with Arrow!
Make your PySpark Data Fly with Arrow!Databricks
 
Zh Tw Introduction To Cloud Computing
Zh Tw Introduction To Cloud ComputingZh Tw Introduction To Cloud Computing
Zh Tw Introduction To Cloud Computingkevin liao
 
An AWS DMS Replication Journey from Oracle to Aurora MySQL
An AWS DMS Replication Journey from Oracle to Aurora MySQLAn AWS DMS Replication Journey from Oracle to Aurora MySQL
An AWS DMS Replication Journey from Oracle to Aurora MySQLMaris Elsins
 
Data Integration Solutions for Airports
Data Integration Solutions for AirportsData Integration Solutions for Airports
Data Integration Solutions for AirportsSafe Software
 
Get the most out of Oracle Data Guard - OOW version
Get the most out of Oracle Data Guard - OOW versionGet the most out of Oracle Data Guard - OOW version
Get the most out of Oracle Data Guard - OOW versionLudovico Caldara
 
Intra mart accel platform 2021winter-en
Intra mart accel platform 2021winter-enIntra mart accel platform 2021winter-en
Intra mart accel platform 2021winter-enNTTDATA INTRAMART
 
Breaking the Monolith road to containers.pdf
Breaking the Monolith road to containers.pdfBreaking the Monolith road to containers.pdf
Breaking the Monolith road to containers.pdfAmazon Web Services
 
MicroProfile Starterで簡単スタート Open Liberty
MicroProfile Starterで簡単スタート Open LibertyMicroProfile Starterで簡単スタート Open Liberty
MicroProfile Starterで簡単スタート Open LibertyTakakiyo Tanaka
 
AWS Stockholm Summit 19- Building serverless applications with GraphQL
AWS Stockholm Summit 19- Building serverless applications with GraphQLAWS Stockholm Summit 19- Building serverless applications with GraphQL
AWS Stockholm Summit 19- Building serverless applications with GraphQLMarcia Villalba
 

Similar to GraphQL Data Loaders - How to feed your GraphQL API with data the smart way (20)

Why you should migrate to GraphQL in 2019
Why you should migrate to GraphQL in 2019Why you should migrate to GraphQL in 2019
Why you should migrate to GraphQL in 2019
 
APIdays Paris 2019 - Real World Graphene: Lessons Learned from Building a Gra...
APIdays Paris 2019 - Real World Graphene: Lessons Learned from Building a Gra...APIdays Paris 2019 - Real World Graphene: Lessons Learned from Building a Gra...
APIdays Paris 2019 - Real World Graphene: Lessons Learned from Building a Gra...
 
Schema-first vs. Code-first approach in GraphQL API development
Schema-first vs. Code-first approach in GraphQL API developmentSchema-first vs. Code-first approach in GraphQL API development
Schema-first vs. Code-first approach in GraphQL API development
 
Ariadne: familiar GraphQL in Python
Ariadne: familiar GraphQL in PythonAriadne: familiar GraphQL in Python
Ariadne: familiar GraphQL in Python
 
Continuous Data Replication into Cloud Storage with Oracle GoldenGate
Continuous Data Replication into Cloud Storage with Oracle GoldenGateContinuous Data Replication into Cloud Storage with Oracle GoldenGate
Continuous Data Replication into Cloud Storage with Oracle GoldenGate
 
Brian Bulkowski : what startups can learn from real-time bidding
Brian Bulkowski : what startups can learn from real-time biddingBrian Bulkowski : what startups can learn from real-time bidding
Brian Bulkowski : what startups can learn from real-time bidding
 
OSDC 2019 | RTO & RPO – Best Practices in Hybrid Architectures by Fernando Honig
OSDC 2019 | RTO & RPO – Best Practices in Hybrid Architectures by Fernando HonigOSDC 2019 | RTO & RPO – Best Practices in Hybrid Architectures by Fernando Honig
OSDC 2019 | RTO & RPO – Best Practices in Hybrid Architectures by Fernando Honig
 
Data Warehouse - Incremental Migration to the Cloud
Data Warehouse - Incremental Migration to the CloudData Warehouse - Incremental Migration to the Cloud
Data Warehouse - Incremental Migration to the Cloud
 
Lessons From Officeworks on Optimising Persistent Storage on AWS (Sponsored b...
Lessons From Officeworks on Optimising Persistent Storage on AWS (Sponsored b...Lessons From Officeworks on Optimising Persistent Storage on AWS (Sponsored b...
Lessons From Officeworks on Optimising Persistent Storage on AWS (Sponsored b...
 
Application and database migration workshop
Application and database migration workshopApplication and database migration workshop
Application and database migration workshop
 
Make your PySpark Data Fly with Arrow!
Make your PySpark Data Fly with Arrow!Make your PySpark Data Fly with Arrow!
Make your PySpark Data Fly with Arrow!
 
Zh Tw Introduction To Cloud Computing
Zh Tw Introduction To Cloud ComputingZh Tw Introduction To Cloud Computing
Zh Tw Introduction To Cloud Computing
 
An AWS DMS Replication Journey from Oracle to Aurora MySQL
An AWS DMS Replication Journey from Oracle to Aurora MySQLAn AWS DMS Replication Journey from Oracle to Aurora MySQL
An AWS DMS Replication Journey from Oracle to Aurora MySQL
 
Data Integration Solutions for Airports
Data Integration Solutions for AirportsData Integration Solutions for Airports
Data Integration Solutions for Airports
 
EDI 2009 Information Everywhere: Understanding New Technologies & Coping with...
EDI 2009 Information Everywhere: Understanding New Technologies & Coping with...EDI 2009 Information Everywhere: Understanding New Technologies & Coping with...
EDI 2009 Information Everywhere: Understanding New Technologies & Coping with...
 
Get the most out of Oracle Data Guard - OOW version
Get the most out of Oracle Data Guard - OOW versionGet the most out of Oracle Data Guard - OOW version
Get the most out of Oracle Data Guard - OOW version
 
Intra mart accel platform 2021winter-en
Intra mart accel platform 2021winter-enIntra mart accel platform 2021winter-en
Intra mart accel platform 2021winter-en
 
Breaking the Monolith road to containers.pdf
Breaking the Monolith road to containers.pdfBreaking the Monolith road to containers.pdf
Breaking the Monolith road to containers.pdf
 
MicroProfile Starterで簡単スタート Open Liberty
MicroProfile Starterで簡単スタート Open LibertyMicroProfile Starterで簡単スタート Open Liberty
MicroProfile Starterで簡単スタート Open Liberty
 
AWS Stockholm Summit 19- Building serverless applications with GraphQL
AWS Stockholm Summit 19- Building serverless applications with GraphQLAWS Stockholm Summit 19- Building serverless applications with GraphQL
AWS Stockholm Summit 19- Building serverless applications with GraphQL
 

Recently uploaded

why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?Watsoo Telematics
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 

Recently uploaded (20)

why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 

GraphQL Data Loaders - How to feed your GraphQL API with data the smart way

  • 1. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARECOPYRIGHT © 2009–2019 MIRUMEE SOFTWARE GraphQL Data Loaders How to feed your GraphQL API with data the smart way
  • 2. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE Jakub Draganek Python Developer @ Mirumee Software Ariadne Saleor
  • 3. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE GRAPHQL API SETUP EXAMPLE
  • 4. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE Schema
  • 5. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE GraphQL query execution
  • 6. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE GraphQL query execution CLIENT QUERY getData() getOtherData()
  • 7. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE GraphQL query
  • 8. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE Building response ■ Parse ■ Validate ■ Execute
  • 9. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE Resolver execution tree
  • 10. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE name kingdoms ruler name house name KINGDOM PERSON HOUSEQUERY
  • 11. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE Resolvers execution flow ■ Receive parent and arguments ■ Fetch / transform data in resolver ■ Wait until finished and iterate on children
  • 12. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE Simple and elegant, what is wrong with that? Things start to get very ugly quickly…
  • 13. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE Give me more data!
  • 14. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE Execution steps ■ run Query.kingdoms ■ for Kingdom run Kingdom.name and Kingdom.ruler ■ for ruler run Person.name, Person.parents, Person.house ■ for kingdom ruler’s parents run Person.name and Person.house ■ for each parent house run House.name ■ … ■ fetch House.name a few more times ■ fetch same Person a few times with everything once again!
  • 15. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE
  • 16. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE N+1 and other problems ■ Repetition of the same data fetching ■ Suboptimal database usage ■ Overloaded external services ■ Data inconsistency
  • 17. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE Solution? ■ Batching ■ Caching ■ Data layer abstraction
  • 18. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE Data layer abstraction QUERY resolver resolver DB Services Data layer abstraction
  • 19. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE DataLoader Generic data fetching layer
  • 20. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE DataLoader ■ Collect keys from every .load() ■ Batch data fetch on event loop tick ■ Each .load() revolves to data ■ Cache data for a single request
  • 21. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE DataLoader loop LOOP load(1) load(2) load(5) batch([1,2,5])resolver DBCACHE resolver
  • 22. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE Async resolver flow load(1) load(2) batch([1,2]) resolver 2 resolver 1 promise promise tick! ⌛ DB {1: “data_1”, 2: “data_2} resolver 1 resolve promise! SOON...
  • 23. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE What is important? ■ Asynchronous environment ■ Single instance of Data Loader per request ■ One DataLoader per GraphQL Type ■ No business logic in the data layer! ■ All data fetching in the batch function
  • 24. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE Where now? ■ Data Loader implementation for your environment ■ Persistent caching ■ Different execution strategies ■ Field level query analysis ■ The sooner the better. Keep the data layer separate
  • 25. COPYRIGHT © 2009–2019 MIRUMEE SOFTWARE THANK YOU! QUESTIONS?