SlideShare a Scribd company logo
1 of 63
Download to read offline
GraphQL BKK 5.0
Meetup, Bangkok, 19th March 2019
● Nimble
● GraphQL FAQ (Tobias)
● Data fetching in resolvers (Michael)
● React + Apollo with TypeScript (Lucas)
● Connect, Talk, Hack until 10pm
No breaks maybe... 😉
2
~ 9.30 pm
Thank you
we ARE passionate software engineers,
product managers and designers
4
jobs.nimblehq.co
5
rubyconfth.com
September 6th & 7th, 2019 - Pullman Bangkok King Power
GraphQL Asia
graphql-asia.org
6
Asia's first GraphQL conference
12th & 13th April, Bangalore, India
Join us and win today
GraphQL FAQ
Tobias Meixner
CTO @ BrikL
19 March 2019
8
😂 😋 😒
1 2 3
Your GraphQL?
GraphQL - A Query Language for
APIs not databases
9
… and more
… and more
… and more
10
Why GraphQL?
● One source of truth
● e.g. using Schema-first
● Contract frontend-backend
● Introspection
● Flexible
● Frontend-driven development
● Use mocking
What is…?
● Schema
○ Blueprint that describes all data types and their relationships
○ What data we can fetched through queries and what data we can
update through mutations
● SDL
○ Schema definition language
● Query
○ Definition to fetch data
● Mutation
○ Definition to update data
● Subscription
○ Definition to subscribe to real-time updates in your data
● Directive
○ Describe alternate runtime execution and type validation behavior
in a GraphQL document
What is…?
● Arguments
○ Passed into your query, mutation, … functions to yield specific
values
● Resolver
○ Functions to resolve data from your data sources based e.g. on
arguments
● Types
○ Strongly typed definitions in your schema
● Fragment
○ Reusable parts of your e.g. query or mutation to avoid
duplication
How to connect to a
GraphQL API?
● Use one of the available frameworks available
in various languages such as React, Angular,
React Native
● Use traditional POST fetch mechanisms
passing your query as JSON string in the body
(axios, etc.)
What language to use?
● So many…
● GraphQL is language agnostic
How to connect legacy
APIs?
● Use GraphQL as layer in front of your existing
APIs
● Can use REST APIs as data sources in your
GraphQL resolvers
○ Same for legacy external APIs
What is schema
stitching?
● Merge other GraphQL schemas into your
schema to create one single layer
○ Can be your GraphQL schema from
different services
○ Can be external GraphQL schemas
(dangerous)
● Once merged you can use another schema
under its namespace
How to do
Authn/Authz?● Client:
○ Use JWT with scoped permissions and
authentication baked into the token
○ Pass JWT/Tokens as Authorization header
● Server:
○ Parse your token/header
○ Pass decoded user into context (optional)
○ Handle in centralized space such as
■ Middleware
■ Edges of your graph i.e. one type per
microservice/permission level
How to handle errors?
● A successful GraphQL query is supposed to
return a JSON object with a root field called
"data".
● If the request fails or partially fails (e.g. because
the user requesting the data doesn’t have the
right access permissions), a second root field
called "errors" is added to the response:
https://facebook.github.io/graphql/draft/#sec-Errors
How to secure a
GraphQL API?
● Ideally handle on network or load balancer level
● Additional options:
○ Maintain registry of allowed queries and
mutations
■ Generate register in build time
○ Can use persisted queries to anonymise
queries
○ Check query complexity to avoid DoS
○ Track query quantity
○ Handle Authn/Authz
How to handle caching?
● Cache in client (difficult)
○ Use existing packages such as Apollo
Client or Redux
● Cache in your datasource layer
○ Redis etc.
○ Cache your REST APIs that are sources of
your GraphQL
● Cache using existing packages
○ Apollo Server generates cache-control
headers then:
■ Use persisted queries with GET
request to a CDN
■ Use memory cache such as LRU
How to test?
● Client:
○ End-to-End testing
○ Use mocked data from GraphQL server
○ Use test frameworks such as
■ MockedProvider in react-apollo
● Server:
○ Mocha/Chai with JSON strings
○ Use packages such as:
■ apollo-server-testing
How to solve n+1?
● Listen to Michael!
How to scale GraphQL
APIs?
● Make GraphQL layer as thing as possible
● Split your schema
○ Schema stitching based on
microservice/product
○ Modularize based on service/types
○ Modularize based on data source
● Make use of subscriptions linked to a queue (e.g.
RabbitMQ)
● Split resolvers into services or serverless
functions
● https://blog.apollographql.com/modularizing-yo
ur-graphql-schema-code-d7f71d5ed5f2
How to get started?
● Follow popular tutorials:
○ https://www.howtographql.com/
○ https://www.apollographql.com/docs/tutorial/introducti
on.html
○ https://advancedreact.com/
○ https://roadtoreact.com/course-details?courseId=THE_
ROAD_TO_GRAPHQL
● Use opinionated/managed GraphQL services:
○ Hasura
○ Prisma
○ AppSync
References
● Read the specs:
○ https://facebook.github.io/graphql/draft/
● https://www.howtographql.com/
● https://www.apollographql.com/docs/tutorial/
introduction.html
● https://www.apollographql.com/docs/resourc
es/faq.html
Data
fetching in
resolvers
I’m Michael
The resolver
function(obj, args, context, info )
Relationships
Schema
Resolver
Type field resolver
Schema
Resolver
21 queries (N+1)
Batching
DataLoader
● Simply utility for batching
● Made by Facebook
21 2 queries
Drawbacks
● Introduces a new layer
● No support for arguments
● So many loaders!
GraphQL Batch Resolver
(graphql-resolve-batch)
● Resolver composition
● GraphQL native
● Supports arguments
GraphQL Batch Resolver
1,674 weekly downloads
192 stars
DataLoader
140,085 weekly downloads
6,911 stars
Fields
The resolver
function(obj, args, context, info)
That’s all...
Questions?
LUCAS
FROM
SCRATCH
Lucas Munhoz
@lnmunhoz
LUCAS
● I am from Brazil
● Making code since 2012
● FullStack Developer
● Independent Freelancer since 2015
● Traveling since 2017
● I am better at coding than talking 😅
Linkedin: @lucasnmunhoz
Github: @lnmunhoz
LUCAS
Let’s code!
LUCAS
Need help with GraphQL?
60
React + Apollo Client
Schema design
Apollo Server
Prisma
Speak to us
Tobias Meixner
tobias@brikl.io
Lucas Munhoz
ln.munhoz@gmail.com
See you at GraphQL Asia!
62
Thank you!Connect, Talk, Hack until 10pm
Credits (Slidetheme)
Special thanks to all the people who made and
released these awesome resources for free:
● Presentation template by SlidesCarnival
● Photographs by Unsplash
63

More Related Content

What's hot

Building Fullstack Serverless GraphQL APIs In The Cloud
Building Fullstack Serverless GraphQL APIs In The CloudBuilding Fullstack Serverless GraphQL APIs In The Cloud
Building Fullstack Serverless GraphQL APIs In The CloudNordic APIs
 
GraphQL Misconfiguration
GraphQL MisconfigurationGraphQL Misconfiguration
GraphQL MisconfigurationHarshit Sengar
 
The Future is Here: ECMAScript 6 in the Wild
The Future is Here: ECMAScript 6 in the WildThe Future is Here: ECMAScript 6 in the Wild
The Future is Here: ECMAScript 6 in the WildAdrian-Tudor Panescu
 
Last Month in PHP - October 2016
Last Month in PHP - October 2016Last Month in PHP - October 2016
Last Month in PHP - October 2016Eric Poe
 
Drupal Brisbane Meetup :: Drupal in late 2017-2018
Drupal Brisbane Meetup :: Drupal in late 2017-2018Drupal Brisbane Meetup :: Drupal in late 2017-2018
Drupal Brisbane Meetup :: Drupal in late 2017-2018Vladimir Roudakov
 
Last Month in PHP - September 2016
Last Month in PHP - September 2016Last Month in PHP - September 2016
Last Month in PHP - September 2016Eric Poe
 
Apache Software Foundation: How To Contribute, with Apache Flink as Example (...
Apache Software Foundation: How To Contribute, with Apache Flink as Example (...Apache Software Foundation: How To Contribute, with Apache Flink as Example (...
Apache Software Foundation: How To Contribute, with Apache Flink as Example (...Apache Flink Taiwan User Group
 
Glowing bear
Glowing bear Glowing bear
Glowing bear thehyve
 
Capstone1 13주차 발표 (morph chart) 수정
Capstone1 13주차 발표 (morph chart) 수정Capstone1 13주차 발표 (morph chart) 수정
Capstone1 13주차 발표 (morph chart) 수정Hyunjoo Yang
 
tranSMART 17.1 technical overview
tranSMART 17.1 technical overview  tranSMART 17.1 technical overview
tranSMART 17.1 technical overview seher room
 
Visual, scalable, and manageable data loading to and from Neo4j with Apache Hop
Visual, scalable, and manageable data loading to and from Neo4j with Apache Hop Visual, scalable, and manageable data loading to and from Neo4j with Apache Hop
Visual, scalable, and manageable data loading to and from Neo4j with Apache Hop Neo4j
 
Mongo and ElasticSearch
Mongo and ElasticSearchMongo and ElasticSearch
Mongo and ElasticSearchSreejith c
 
Code:Nation Tech Stack
Code:Nation Tech StackCode:Nation Tech Stack
Code:Nation Tech StackElton Minetto
 

What's hot (18)

Building Fullstack Serverless GraphQL APIs In The Cloud
Building Fullstack Serverless GraphQL APIs In The CloudBuilding Fullstack Serverless GraphQL APIs In The Cloud
Building Fullstack Serverless GraphQL APIs In The Cloud
 
GraphQL Misconfiguration
GraphQL MisconfigurationGraphQL Misconfiguration
GraphQL Misconfiguration
 
Attacking GraphQL
Attacking GraphQLAttacking GraphQL
Attacking GraphQL
 
The Future is Here: ECMAScript 6 in the Wild
The Future is Here: ECMAScript 6 in the WildThe Future is Here: ECMAScript 6 in the Wild
The Future is Here: ECMAScript 6 in the Wild
 
Last Month in PHP - October 2016
Last Month in PHP - October 2016Last Month in PHP - October 2016
Last Month in PHP - October 2016
 
Drupal Brisbane Meetup :: Drupal in late 2017-2018
Drupal Brisbane Meetup :: Drupal in late 2017-2018Drupal Brisbane Meetup :: Drupal in late 2017-2018
Drupal Brisbane Meetup :: Drupal in late 2017-2018
 
Last Month in PHP - September 2016
Last Month in PHP - September 2016Last Month in PHP - September 2016
Last Month in PHP - September 2016
 
Apache Software Foundation: How To Contribute, with Apache Flink as Example (...
Apache Software Foundation: How To Contribute, with Apache Flink as Example (...Apache Software Foundation: How To Contribute, with Apache Flink as Example (...
Apache Software Foundation: How To Contribute, with Apache Flink as Example (...
 
Are we there yet?
Are we there yet?Are we there yet?
Are we there yet?
 
Go at Skroutz
Go at SkroutzGo at Skroutz
Go at Skroutz
 
Glowing bear
Glowing bear Glowing bear
Glowing bear
 
Capstone1 13주차 발표 (morph chart) 수정
Capstone1 13주차 발표 (morph chart) 수정Capstone1 13주차 발표 (morph chart) 수정
Capstone1 13주차 발표 (morph chart) 수정
 
tranSMART 17.1 technical overview
tranSMART 17.1 technical overview  tranSMART 17.1 technical overview
tranSMART 17.1 technical overview
 
Overcome a Frontier
Overcome a FrontierOvercome a Frontier
Overcome a Frontier
 
Visual, scalable, and manageable data loading to and from Neo4j with Apache Hop
Visual, scalable, and manageable data loading to and from Neo4j with Apache Hop Visual, scalable, and manageable data loading to and from Neo4j with Apache Hop
Visual, scalable, and manageable data loading to and from Neo4j with Apache Hop
 
GraphQL Search
GraphQL SearchGraphQL Search
GraphQL Search
 
Mongo and ElasticSearch
Mongo and ElasticSearchMongo and ElasticSearch
Mongo and ElasticSearch
 
Code:Nation Tech Stack
Code:Nation Tech StackCode:Nation Tech Stack
Code:Nation Tech Stack
 

Similar to GraphQL Bangkok meetup 5.0

Kotlin REST & GraphQL API
Kotlin REST & GraphQL APIKotlin REST & GraphQL API
Kotlin REST & GraphQL APISean O'Brien
 
Marco Liberati - Graph analytics
Marco Liberati - Graph analyticsMarco Liberati - Graph analytics
Marco Liberati - Graph analyticsCodemotion
 
Modular GraphQL with Schema Stitching
Modular GraphQL with Schema StitchingModular GraphQL with Schema Stitching
Modular GraphQL with Schema StitchingSashko Stubailo
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQLKnoldus Inc.
 
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
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL StackSashko Stubailo
 
GraphQL API Crafts presentation
GraphQL API Crafts presentationGraphQL API Crafts presentation
GraphQL API Crafts presentationSudheer J
 
GraphQL Meetup Bangkok 4.0
GraphQL Meetup Bangkok 4.0GraphQL Meetup Bangkok 4.0
GraphQL Meetup Bangkok 4.0Tobias Meixner
 
Mumbai MuleSoft Meetup #17 - GraphQL
Mumbai MuleSoft Meetup #17 - GraphQLMumbai MuleSoft Meetup #17 - GraphQL
Mumbai MuleSoft Meetup #17 - GraphQLAkshata Sawant
 
Modern APIs with GraphQL
Modern APIs with GraphQLModern APIs with GraphQL
Modern APIs with GraphQLTaikai
 
Graphql Overview By Chirag Dodia
Graphql Overview By Chirag DodiaGraphql Overview By Chirag Dodia
Graphql Overview By Chirag Dodiavijaygolani
 
API Management for GraphQL
API Management for GraphQLAPI Management for GraphQL
API Management for GraphQLWSO2
 
Green Custard Friday Talk 8: GraphQL
Green Custard Friday Talk 8: GraphQLGreen Custard Friday Talk 8: GraphQL
Green Custard Friday Talk 8: GraphQLGreen Custard
 
Graphql presentation
Graphql presentationGraphql presentation
Graphql presentationVibhor Grover
 
Architecting Analytic Pipelines on GCP - Chicago Cloud Conference 2020
Architecting Analytic Pipelines on GCP - Chicago Cloud Conference 2020Architecting Analytic Pipelines on GCP - Chicago Cloud Conference 2020
Architecting Analytic Pipelines on GCP - Chicago Cloud Conference 2020Mariano Gonzalez
 
Building Fullstack Graph Applications With Neo4j
Building Fullstack Graph Applications With Neo4j Building Fullstack Graph Applications With Neo4j
Building Fullstack Graph Applications With Neo4j Neo4j
 
Training Week: GraphQL 2022
Training Week: GraphQL 2022Training Week: GraphQL 2022
Training Week: GraphQL 2022Neo4j
 
GraphQL @ Manc.JS (March 2018)
GraphQL @ Manc.JS (March 2018)GraphQL @ Manc.JS (March 2018)
GraphQL @ Manc.JS (March 2018)Chris Grice
 
Upleveling Analytics with Kafka with Amy Chen
Upleveling Analytics with Kafka with Amy ChenUpleveling Analytics with Kafka with Amy Chen
Upleveling Analytics with Kafka with Amy ChenHostedbyConfluent
 

Similar to GraphQL Bangkok meetup 5.0 (20)

Kotlin REST & GraphQL API
Kotlin REST & GraphQL APIKotlin REST & GraphQL API
Kotlin REST & GraphQL API
 
Marco Liberati - Graph analytics
Marco Liberati - Graph analyticsMarco Liberati - Graph analytics
Marco Liberati - Graph analytics
 
Modular GraphQL with Schema Stitching
Modular GraphQL with Schema StitchingModular GraphQL with Schema Stitching
Modular GraphQL with Schema Stitching
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
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
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL Stack
 
GraphQL API Crafts presentation
GraphQL API Crafts presentationGraphQL API Crafts presentation
GraphQL API Crafts presentation
 
GraphQL Meetup Bangkok 4.0
GraphQL Meetup Bangkok 4.0GraphQL Meetup Bangkok 4.0
GraphQL Meetup Bangkok 4.0
 
Mumbai MuleSoft Meetup #17 - GraphQL
Mumbai MuleSoft Meetup #17 - GraphQLMumbai MuleSoft Meetup #17 - GraphQL
Mumbai MuleSoft Meetup #17 - GraphQL
 
Modern APIs with GraphQL
Modern APIs with GraphQLModern APIs with GraphQL
Modern APIs with GraphQL
 
GraphQL + relay
GraphQL + relayGraphQL + relay
GraphQL + relay
 
Graphql Overview By Chirag Dodia
Graphql Overview By Chirag DodiaGraphql Overview By Chirag Dodia
Graphql Overview By Chirag Dodia
 
API Management for GraphQL
API Management for GraphQLAPI Management for GraphQL
API Management for GraphQL
 
Green Custard Friday Talk 8: GraphQL
Green Custard Friday Talk 8: GraphQLGreen Custard Friday Talk 8: GraphQL
Green Custard Friday Talk 8: GraphQL
 
Graphql presentation
Graphql presentationGraphql presentation
Graphql presentation
 
Architecting Analytic Pipelines on GCP - Chicago Cloud Conference 2020
Architecting Analytic Pipelines on GCP - Chicago Cloud Conference 2020Architecting Analytic Pipelines on GCP - Chicago Cloud Conference 2020
Architecting Analytic Pipelines on GCP - Chicago Cloud Conference 2020
 
Building Fullstack Graph Applications With Neo4j
Building Fullstack Graph Applications With Neo4j Building Fullstack Graph Applications With Neo4j
Building Fullstack Graph Applications With Neo4j
 
Training Week: GraphQL 2022
Training Week: GraphQL 2022Training Week: GraphQL 2022
Training Week: GraphQL 2022
 
GraphQL @ Manc.JS (March 2018)
GraphQL @ Manc.JS (March 2018)GraphQL @ Manc.JS (March 2018)
GraphQL @ Manc.JS (March 2018)
 
Upleveling Analytics with Kafka with Amy Chen
Upleveling Analytics with Kafka with Amy ChenUpleveling Analytics with Kafka with Amy Chen
Upleveling Analytics with Kafka with Amy Chen
 

More from Tobias Meixner

GraphQL Server - Single point of opportunities
GraphQL Server - Single point of opportunitiesGraphQL Server - Single point of opportunities
GraphQL Server - Single point of opportunitiesTobias Meixner
 
GraphQL Bangkok Meetup 6.0
GraphQL Bangkok Meetup 6.0GraphQL Bangkok Meetup 6.0
GraphQL Bangkok Meetup 6.0Tobias Meixner
 
BrikL - A GraphQL Native - GraphQL Asia 2019
BrikL - A GraphQL Native - GraphQL Asia 2019BrikL - A GraphQL Native - GraphQL Asia 2019
BrikL - A GraphQL Native - GraphQL Asia 2019Tobias Meixner
 
GraphQL Meetup Bangkok 3.0
GraphQL Meetup Bangkok 3.0GraphQL Meetup Bangkok 3.0
GraphQL Meetup Bangkok 3.0Tobias Meixner
 
GraphQL Bangkok Meetup 2.0
GraphQL Bangkok Meetup 2.0GraphQL Bangkok Meetup 2.0
GraphQL Bangkok Meetup 2.0Tobias Meixner
 

More from Tobias Meixner (7)

Public GraphQL APIs
Public GraphQL APIsPublic GraphQL APIs
Public GraphQL APIs
 
GraphQL Server - Single point of opportunities
GraphQL Server - Single point of opportunitiesGraphQL Server - Single point of opportunities
GraphQL Server - Single point of opportunities
 
GraphQL Bangkok Meetup 6.0
GraphQL Bangkok Meetup 6.0GraphQL Bangkok Meetup 6.0
GraphQL Bangkok Meetup 6.0
 
BrikL - A GraphQL Native - GraphQL Asia 2019
BrikL - A GraphQL Native - GraphQL Asia 2019BrikL - A GraphQL Native - GraphQL Asia 2019
BrikL - A GraphQL Native - GraphQL Asia 2019
 
GraphQL Asia Speakers
GraphQL Asia SpeakersGraphQL Asia Speakers
GraphQL Asia Speakers
 
GraphQL Meetup Bangkok 3.0
GraphQL Meetup Bangkok 3.0GraphQL Meetup Bangkok 3.0
GraphQL Meetup Bangkok 3.0
 
GraphQL Bangkok Meetup 2.0
GraphQL Bangkok Meetup 2.0GraphQL Bangkok Meetup 2.0
GraphQL Bangkok Meetup 2.0
 

Recently uploaded

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 

Recently uploaded (20)

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

GraphQL Bangkok meetup 5.0

  • 1. GraphQL BKK 5.0 Meetup, Bangkok, 19th March 2019
  • 2. ● Nimble ● GraphQL FAQ (Tobias) ● Data fetching in resolvers (Michael) ● React + Apollo with TypeScript (Lucas) ● Connect, Talk, Hack until 10pm No breaks maybe... 😉 2 ~ 9.30 pm
  • 4. we ARE passionate software engineers, product managers and designers 4 jobs.nimblehq.co
  • 5. 5 rubyconfth.com September 6th & 7th, 2019 - Pullman Bangkok King Power
  • 6. GraphQL Asia graphql-asia.org 6 Asia's first GraphQL conference 12th & 13th April, Bangalore, India Join us and win today
  • 7. GraphQL FAQ Tobias Meixner CTO @ BrikL 19 March 2019
  • 8. 8 😂 😋 😒 1 2 3 Your GraphQL?
  • 9. GraphQL - A Query Language for APIs not databases 9 … and more … and more … and more
  • 10. 10
  • 11. Why GraphQL? ● One source of truth ● e.g. using Schema-first ● Contract frontend-backend ● Introspection ● Flexible ● Frontend-driven development ● Use mocking
  • 12. What is…? ● Schema ○ Blueprint that describes all data types and their relationships ○ What data we can fetched through queries and what data we can update through mutations ● SDL ○ Schema definition language ● Query ○ Definition to fetch data ● Mutation ○ Definition to update data ● Subscription ○ Definition to subscribe to real-time updates in your data ● Directive ○ Describe alternate runtime execution and type validation behavior in a GraphQL document
  • 13. What is…? ● Arguments ○ Passed into your query, mutation, … functions to yield specific values ● Resolver ○ Functions to resolve data from your data sources based e.g. on arguments ● Types ○ Strongly typed definitions in your schema ● Fragment ○ Reusable parts of your e.g. query or mutation to avoid duplication
  • 14. How to connect to a GraphQL API? ● Use one of the available frameworks available in various languages such as React, Angular, React Native ● Use traditional POST fetch mechanisms passing your query as JSON string in the body (axios, etc.)
  • 15. What language to use? ● So many… ● GraphQL is language agnostic
  • 16. How to connect legacy APIs? ● Use GraphQL as layer in front of your existing APIs ● Can use REST APIs as data sources in your GraphQL resolvers ○ Same for legacy external APIs
  • 17. What is schema stitching? ● Merge other GraphQL schemas into your schema to create one single layer ○ Can be your GraphQL schema from different services ○ Can be external GraphQL schemas (dangerous) ● Once merged you can use another schema under its namespace
  • 18. How to do Authn/Authz?● Client: ○ Use JWT with scoped permissions and authentication baked into the token ○ Pass JWT/Tokens as Authorization header ● Server: ○ Parse your token/header ○ Pass decoded user into context (optional) ○ Handle in centralized space such as ■ Middleware ■ Edges of your graph i.e. one type per microservice/permission level
  • 19. How to handle errors? ● A successful GraphQL query is supposed to return a JSON object with a root field called "data". ● If the request fails or partially fails (e.g. because the user requesting the data doesn’t have the right access permissions), a second root field called "errors" is added to the response: https://facebook.github.io/graphql/draft/#sec-Errors
  • 20. How to secure a GraphQL API? ● Ideally handle on network or load balancer level ● Additional options: ○ Maintain registry of allowed queries and mutations ■ Generate register in build time ○ Can use persisted queries to anonymise queries ○ Check query complexity to avoid DoS ○ Track query quantity ○ Handle Authn/Authz
  • 21. How to handle caching? ● Cache in client (difficult) ○ Use existing packages such as Apollo Client or Redux ● Cache in your datasource layer ○ Redis etc. ○ Cache your REST APIs that are sources of your GraphQL ● Cache using existing packages ○ Apollo Server generates cache-control headers then: ■ Use persisted queries with GET request to a CDN ■ Use memory cache such as LRU
  • 22. How to test? ● Client: ○ End-to-End testing ○ Use mocked data from GraphQL server ○ Use test frameworks such as ■ MockedProvider in react-apollo ● Server: ○ Mocha/Chai with JSON strings ○ Use packages such as: ■ apollo-server-testing
  • 23. How to solve n+1? ● Listen to Michael!
  • 24. How to scale GraphQL APIs? ● Make GraphQL layer as thing as possible ● Split your schema ○ Schema stitching based on microservice/product ○ Modularize based on service/types ○ Modularize based on data source ● Make use of subscriptions linked to a queue (e.g. RabbitMQ) ● Split resolvers into services or serverless functions ● https://blog.apollographql.com/modularizing-yo ur-graphql-schema-code-d7f71d5ed5f2
  • 25. How to get started? ● Follow popular tutorials: ○ https://www.howtographql.com/ ○ https://www.apollographql.com/docs/tutorial/introducti on.html ○ https://advancedreact.com/ ○ https://roadtoreact.com/course-details?courseId=THE_ ROAD_TO_GRAPHQL ● Use opinionated/managed GraphQL services: ○ Hasura ○ Prisma ○ AppSync
  • 26. References ● Read the specs: ○ https://facebook.github.io/graphql/draft/ ● https://www.howtographql.com/ ● https://www.apollographql.com/docs/tutorial/ introduction.html ● https://www.apollographql.com/docs/resourc es/faq.html
  • 30.
  • 32.
  • 36.
  • 39. DataLoader ● Simply utility for batching ● Made by Facebook
  • 40.
  • 41.
  • 42.
  • 44. Drawbacks ● Introduces a new layer ● No support for arguments ● So many loaders!
  • 45. GraphQL Batch Resolver (graphql-resolve-batch) ● Resolver composition ● GraphQL native ● Supports arguments
  • 46.
  • 47.
  • 48.
  • 49.
  • 50. GraphQL Batch Resolver 1,674 weekly downloads 192 stars DataLoader 140,085 weekly downloads 6,911 stars
  • 52.
  • 54.
  • 57. LUCAS ● I am from Brazil ● Making code since 2012 ● FullStack Developer ● Independent Freelancer since 2015 ● Traveling since 2017 ● I am better at coding than talking 😅 Linkedin: @lucasnmunhoz Github: @lnmunhoz
  • 59. LUCAS
  • 60. Need help with GraphQL? 60 React + Apollo Client Schema design Apollo Server Prisma Speak to us Tobias Meixner tobias@brikl.io Lucas Munhoz ln.munhoz@gmail.com
  • 61. See you at GraphQL Asia!
  • 62. 62 Thank you!Connect, Talk, Hack until 10pm
  • 63. Credits (Slidetheme) Special thanks to all the people who made and released these awesome resources for free: ● Presentation template by SlidesCarnival ● Photographs by Unsplash 63