SlideShare a Scribd company logo
Create flexible React applications using GraphQL
Maurice de Beijer - @mauricedb
ROME - APRIL 13/14 2018
Topics
 What is GraphQL and why use it?
 Using GraphQL from a React application
 Optimizing GraphQL queries
 Mutating data
ABL - The Problem Solver 2
 Maurice de Beijer
 The Problem Solver
 Microsoft MVP
 Freelance developer/instructor
 Twitter: @mauricedb
 Web: http://www.TheProblemSolver.nl
 E-mail: maurice.de.beijer@gmail.com
ABL - The Problem Solver 3
Skillshare
Courses
ABL - The Problem Solver 4
What is
GraphQL?
GraphQL is a query language for APIs
Written at Facebook
ABL - The Problem Solver 5
ABL - The Problem Solver 6
What is
GraphQL?
 A way to query hierarchical data over HTTP
 The server provides a data definition
 The client validates queries again this definition
 The client query defines shape of data loaded
 Both shape and number of records
 Data sets as well as fields can be parameterized
ABL - The Problem Solver 7
Why use
GraphQL?
 Only fetch data you really need
 Different clients need different result shapes
 Consolidate different API’s
 Playground to test queries
 Backed by strongly typed schema
 Clear separation between queries and mutations
 CQRS for the win 
 And many more advantages
 Subscriptions for data changes
 Deprecate old fields that are not used
ABL - The Problem Solver 8
Clients have
different
requirements
GraphQL Endpoint
ABL - The Problem Solver 9
Consolidate
different
API’s
GraphQL Endpoint
Tips
API
Movies
REST
API
Users
DB
ABL - The Problem Solver 10
GraphQL
versus Rest
Rest
 Server decides what you get 👎
 No standard schema 👎
 Several flavors
 No playground to test 👎
 Caching using HTTP 👍
GraphQL
 Server decides what’s available 👍
 Client decides what to load 👍
 Strongly typed schema 👍
 Interactive playground 👍
 To test queries
ABL - The Problem Solver 11
GraphQL
Clients
ABL - The Problem Solver 12
ABL - The Problem Solver 13
Getting
started with
Apollo
 Just three NPM packages needed:
 apollo-boost
 react-apollo
 graphql
ABL - The Problem Solver 14
ABL - The Problem Solver 15
The
ApolloClient
class
 Use the class from apollo-boost!
 Comes preconfigured with sensible defaults
ABL - The Problem Solver 16
ABL - The Problem Solver 17
The
ApolloProvider
component
 Provides the rest of the application access to the
ApolloClient
ABL - The Problem Solver 18
ABL - The Problem Solver 19
TheGQL
query
 Define the data requirements
 Add parameters as needed
ABL - The Problem Solver 20
The
Query
component
 Executes the query using the provided
ApolloClient
 Uses the render props syntax with the QueryResult
 There is also a graphql HOC available
ABL - The Problem Solver 21
The
QueryResult
ABL - The Problem Solver 22
Defining
query
fragments
 Each component defines its own data
requirements
ABL - The Problem Solver 23
Using
query
fragments
 These are combined into one single query
ABL - The Problem Solver 24
Batching
HTTP
Requests
 Multiple queries result in multiple HTTP request
 Batch these into a single request using the BatchHttpLink
 Use the ApolloClient from apollo-client
 TheApolloClient from apollo-boost doesn’t support this (yet)
ABL - The Problem Solver 25
Mutating
data
 Any updates can be send to the server using
mutations
 Calls a function on the server with the specified
data
ABL - The Problem Solver 26
TheGQL
mutation
 Defines the data to send to the server
 And the data we want to receive on success
ABL - The Problem Solver 27
The
Mutation
component
 Executes the mutation using the provided
ApolloClient
 Uses the render props syntax with the function to
mutate
 There is also an graphql HOC available
 Use the update function to update caches
ABL - The Problem Solver 28
Executing
the mutation
 Provide the mutation parameters using the
variables object
ABL - The Problem Solver 29
Conclusion
 GraphQL is a great way to query API’s over HTTP
 The server determines what is possible
 The client controls what is loaded
 A great way to consolidate multiple REST services
 Queries are validated against a type system
 Updates can be done using mutations
ABL - The Problem Solver 30
MauricedeBeijer
@mauricedb
ABL - The Problem Solver 31

More Related Content

What's hot (20)

GraphQL + relay
GraphQL + relay
Cédric GILLET
 
SFScon18 - Kurt Ranalter - Leonhard Holzer - API level regression testing: a ...
SFScon18 - Kurt Ranalter - Leonhard Holzer - API level regression testing: a ...
South Tyrol Free Software Conference
 
GraphQL: The Missing Link Between Frontend and Backend Devs
GraphQL: The Missing Link Between Frontend and Backend Devs
Sashko Stubailo
 
Introduction to graphQL
Introduction to graphQL
Muhilvarnan V
 
Getting started with GraphQL
Getting started with GraphQL
Thiago Colares
 
GraphQL Search
GraphQL Search
Artem Shtatnov
 
GraphQL & Relay
GraphQL & Relay
Viacheslav Slinko
 
Bringing a public GraphQL API from the whiteboard to production
Bringing a public GraphQL API from the whiteboard to production
yann_s
 
GraphQL Advanced
GraphQL Advanced
LeanIX GmbH
 
GitLab Product update May 16
GitLab Product update May 16
🌍 Job van der Voort
 
GraphQL With Relay Part Deux
GraphQL With Relay Part Deux
Brad Pillow
 
GraphQL.net
GraphQL.net
Tyler Ayers
 
Bringing a public GraphQL API from beta to production ready
Bringing a public GraphQL API from beta to production ready
yann_s
 
Building Reliable Applications Using React, .NET & Azure
Building Reliable Applications Using React, .NET & Azure
Maurice De Beijer [MVP]
 
GitLab Product Update June 20
GitLab Product Update June 20
🌍 Job van der Voort
 
[Portland 365Sat] PCF Custom Controls
[Portland 365Sat] PCF Custom Controls
⚡ Danish Naglekar
 
Real Time Serverless Polling App
Real Time Serverless Polling App
Srushith Repakula
 
GraphQL
GraphQL
Cédric GILLET
 
London React August - GraphQL at The Financial Times - Viktor Charypar
London React August - GraphQL at The Financial Times - Viktor Charypar
React London Community
 
Product update aug_29
Product update aug_29
🌍 Job van der Voort
 
SFScon18 - Kurt Ranalter - Leonhard Holzer - API level regression testing: a ...
SFScon18 - Kurt Ranalter - Leonhard Holzer - API level regression testing: a ...
South Tyrol Free Software Conference
 
GraphQL: The Missing Link Between Frontend and Backend Devs
GraphQL: The Missing Link Between Frontend and Backend Devs
Sashko Stubailo
 
Introduction to graphQL
Introduction to graphQL
Muhilvarnan V
 
Getting started with GraphQL
Getting started with GraphQL
Thiago Colares
 
Bringing a public GraphQL API from the whiteboard to production
Bringing a public GraphQL API from the whiteboard to production
yann_s
 
GraphQL Advanced
GraphQL Advanced
LeanIX GmbH
 
GraphQL With Relay Part Deux
GraphQL With Relay Part Deux
Brad Pillow
 
Bringing a public GraphQL API from beta to production ready
Bringing a public GraphQL API from beta to production ready
yann_s
 
Building Reliable Applications Using React, .NET & Azure
Building Reliable Applications Using React, .NET & Azure
Maurice De Beijer [MVP]
 
[Portland 365Sat] PCF Custom Controls
[Portland 365Sat] PCF Custom Controls
⚡ Danish Naglekar
 
Real Time Serverless Polling App
Real Time Serverless Polling App
Srushith Repakula
 
London React August - GraphQL at The Financial Times - Viktor Charypar
London React August - GraphQL at The Financial Times - Viktor Charypar
React London Community
 

Similar to Create flexible react applications using GraphQL API's (20)

GraphQL Bangkok meetup 5.0
GraphQL Bangkok meetup 5.0
Tobias Meixner
 
react-apollo
react-apollo
Stephen McElhinney
 
Graphql presentation
Graphql presentation
Vibhor Grover
 
Building Fullstack Serverless GraphQL APIs In The Cloud
Building Fullstack Serverless GraphQL APIs In The Cloud
Nordic APIs
 
GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018
Sashko Stubailo
 
React inter3
React inter3
Oswald Campesato
 
GraphQL vs. (the) REST
GraphQL vs. (the) REST
coliquio GmbH
 
Introduction to Graph QL
Introduction to Graph QL
Deepak More
 
React and GraphQL at Stripe
React and GraphQL at Stripe
Sashko Stubailo
 
Graphql
Graphql
Girish Talekar
 
Elixir + GraphQL = Absinthe 2019.04.10
Elixir + GraphQL = Absinthe 2019.04.10
Alexander Knowles
 
The Apollo and GraphQL Stack
The Apollo and GraphQL Stack
Sashko Stubailo
 
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
React Conf Brasil
 
GraphQL - Tidepool Labs
GraphQL - Tidepool Labs
Harutyun Abgaryan
 
GraphQL the holy contract between client and server
GraphQL the holy contract between client and server
Pavel Chertorogov
 
23003471225PPT.pptx
23003471225PPT.pptx
annalakshmi35
 
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
GreeceJS
 
Shift Remote: WEB - GraphQL and React – Quick Start - Dubravko Bogovic (Infobip)
Shift Remote: WEB - GraphQL and React – Quick Start - Dubravko Bogovic (Infobip)
Shift Conference
 
Introduction to GraphQL for beginners
Introduction to GraphQL for beginners
Martin Pham
 
React & GraphQL
React & GraphQL
Nikolas Burk
 
GraphQL Bangkok meetup 5.0
GraphQL Bangkok meetup 5.0
Tobias Meixner
 
Graphql presentation
Graphql presentation
Vibhor Grover
 
Building Fullstack Serverless GraphQL APIs In The Cloud
Building Fullstack Serverless GraphQL APIs In The Cloud
Nordic APIs
 
GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018
Sashko Stubailo
 
GraphQL vs. (the) REST
GraphQL vs. (the) REST
coliquio GmbH
 
Introduction to Graph QL
Introduction to Graph QL
Deepak More
 
React and GraphQL at Stripe
React and GraphQL at Stripe
Sashko Stubailo
 
Elixir + GraphQL = Absinthe 2019.04.10
Elixir + GraphQL = Absinthe 2019.04.10
Alexander Knowles
 
The Apollo and GraphQL Stack
The Apollo and GraphQL Stack
Sashko Stubailo
 
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
React Conf Brasil
 
GraphQL the holy contract between client and server
GraphQL the holy contract between client and server
Pavel Chertorogov
 
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
GreeceJS
 
Shift Remote: WEB - GraphQL and React – Quick Start - Dubravko Bogovic (Infobip)
Shift Remote: WEB - GraphQL and React – Quick Start - Dubravko Bogovic (Infobip)
Shift Conference
 
Introduction to GraphQL for beginners
Introduction to GraphQL for beginners
Martin Pham
 
Ad

More from Maurice De Beijer [MVP] (20)

Production-ready Next.js App with Cursor AI
Production-ready Next.js App with Cursor AI
Maurice De Beijer [MVP]
 
Building Robust Web Applications with Test-Driven Development and Playwright:...
Building Robust Web Applications with Test-Driven Development and Playwright:...
Maurice De Beijer [MVP]
 
Mastering React Server Components and Server Actions in React 19
Mastering React Server Components and Server Actions in React 19
Maurice De Beijer [MVP]
 
Practice TypeScript Techniques Building React Server Components App
Practice TypeScript Techniques Building React Server Components App
Maurice De Beijer [MVP]
 
A foolproof Way to Estimate a Software Project
A foolproof Way to Estimate a Software Project
Maurice De Beijer [MVP]
 
Surati Tech Talks 2022 / Build reliable Svelte applications using Cypress
Surati Tech Talks 2022 / Build reliable Svelte applications using Cypress
Maurice De Beijer [MVP]
 
Build reliable Svelte applications using Cypress
Build reliable Svelte applications using Cypress
Maurice De Beijer [MVP]
 
Building Reliable Applications Using React, .NET & Azure
Building Reliable Applications Using React, .NET & Azure
Maurice De Beijer [MVP]
 
Concurrent Rendering Adventures in React 18
Concurrent Rendering Adventures in React 18
Maurice De Beijer [MVP]
 
Building reliable applications with React, C#, and Azure
Building reliable applications with React, C#, and Azure
Maurice De Beijer [MVP]
 
Building large and scalable mission critical applications with React
Building large and scalable mission critical applications with React
Maurice De Beijer [MVP]
 
Why I am hooked on the future of React
Why I am hooked on the future of React
Maurice De Beijer [MVP]
 
Building reliable web applications using Cypress
Building reliable web applications using Cypress
Maurice De Beijer [MVP]
 
Getting started with React Suspense and concurrent rendering
Getting started with React Suspense and concurrent rendering
Maurice De Beijer [MVP]
 
React suspense, not just for Alfred Hitchcock
React suspense, not just for Alfred Hitchcock
Maurice De Beijer [MVP]
 
From zero to hero with the Reactive extensions for JavaScript
From zero to hero with the Reactive extensions for JavaScript
Maurice De Beijer [MVP]
 
Why I am hooked on the future of React
Why I am hooked on the future of React
Maurice De Beijer [MVP]
 
The new React
The new React
Maurice De Beijer [MVP]
 
From zero to hero with the reactive extensions for JavaScript
From zero to hero with the reactive extensions for JavaScript
Maurice De Beijer [MVP]
 
Why I am hooked on the future of React
Why I am hooked on the future of React
Maurice De Beijer [MVP]
 
Production-ready Next.js App with Cursor AI
Production-ready Next.js App with Cursor AI
Maurice De Beijer [MVP]
 
Building Robust Web Applications with Test-Driven Development and Playwright:...
Building Robust Web Applications with Test-Driven Development and Playwright:...
Maurice De Beijer [MVP]
 
Mastering React Server Components and Server Actions in React 19
Mastering React Server Components and Server Actions in React 19
Maurice De Beijer [MVP]
 
Practice TypeScript Techniques Building React Server Components App
Practice TypeScript Techniques Building React Server Components App
Maurice De Beijer [MVP]
 
A foolproof Way to Estimate a Software Project
A foolproof Way to Estimate a Software Project
Maurice De Beijer [MVP]
 
Surati Tech Talks 2022 / Build reliable Svelte applications using Cypress
Surati Tech Talks 2022 / Build reliable Svelte applications using Cypress
Maurice De Beijer [MVP]
 
Build reliable Svelte applications using Cypress
Build reliable Svelte applications using Cypress
Maurice De Beijer [MVP]
 
Building Reliable Applications Using React, .NET & Azure
Building Reliable Applications Using React, .NET & Azure
Maurice De Beijer [MVP]
 
Concurrent Rendering Adventures in React 18
Concurrent Rendering Adventures in React 18
Maurice De Beijer [MVP]
 
Building reliable applications with React, C#, and Azure
Building reliable applications with React, C#, and Azure
Maurice De Beijer [MVP]
 
Building large and scalable mission critical applications with React
Building large and scalable mission critical applications with React
Maurice De Beijer [MVP]
 
Building reliable web applications using Cypress
Building reliable web applications using Cypress
Maurice De Beijer [MVP]
 
Getting started with React Suspense and concurrent rendering
Getting started with React Suspense and concurrent rendering
Maurice De Beijer [MVP]
 
React suspense, not just for Alfred Hitchcock
React suspense, not just for Alfred Hitchcock
Maurice De Beijer [MVP]
 
From zero to hero with the Reactive extensions for JavaScript
From zero to hero with the Reactive extensions for JavaScript
Maurice De Beijer [MVP]
 
From zero to hero with the reactive extensions for JavaScript
From zero to hero with the reactive extensions for JavaScript
Maurice De Beijer [MVP]
 
Ad

Recently uploaded (20)

Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Supporting the NextGen 911 Digital Transformation with FME
Supporting the NextGen 911 Digital Transformation with FME
Safe Software
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Introduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUE
Google Developer Group On Campus European Universities in Egypt
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
SOFTTECHHUB
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
Edge AI and Vision Alliance
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Supporting the NextGen 911 Digital Transformation with FME
Supporting the NextGen 911 Digital Transformation with FME
Safe Software
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
SOFTTECHHUB
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
Edge AI and Vision Alliance
 

Create flexible react applications using GraphQL API's

Editor's Notes

  • #12: https://raw.githubusercontent.com/sogko/graphql-shorthand-notation-cheat-sheet/master/graphql-shorthand-notation-cheat-sheet.png
  • #31: https://www.flickr.com/photos/krupptastic/4738992473