SlideShare a Scribd company logo
GraphQL + Relay
@telligcirdec + @catelandaxel
Cédric GILLET
Développeur JAVA /
Architect
Axel CATELAND
Développeur Frontend /
Leadtech Front
Bientôt =>
GraphQL
Specification
The boring part
What is GraphQL ?
● An open sourced specification edited by Facebook still in draft
● Define a query language to query, fetch and mutate data from
any datasources in a declarative way
What is NOT GraphQL ?
● NOT a framework
● NOT specific to a language
● NOT as easy as you think
Keys concepts
● Hierarchical : a GraphQL query is a hierarchical set of fields
● Product-centric : the consumer decide what and how
● Strong-typing : queries are syntactically checked and provided
data are type safe
● Introspective : clients and tools can query the type system
using the GraphQL syntax
● Application-layer protocol : use it via FTP, you fools !!
(hidden) Keys concepts
● You gonna need some cache
● You gonna need some papers and a good knowledge of your
data
● You gonna need some red bull
GraphQL
Implementation
Exploitation
May the force be with you !
Meet SWAPI
A P I
SWAPI
Meet SWAPI
● The Star Wars API, or "swapi" (Swah-pee) is the
world's first quantified and programmatically-
accessible data source for all the data from the Star
Wars canon universe!
● All the data is accessible through a HTTP web API.
SWAPI
SWAPI Examples
GO ! GO ! GO !
SWAPI
GraphQL : Mapping
Consist of creating links between the backend data and graphql
fields
SWAPI
GraphQL : TypingSWAPI
GraphQL : Typing
● Consist of adding a strong type to GraphQL fields
● Exhaustive list of types
○ Scalar
■ Int / Float / String / Boolean / ID
○ Object
○ Interface
○ Union
○ Enum
○ List
○ Input Object
○ NonNull
SWAPI
GraphQL : Introspection
A GraphQL server supports introspection over its schema by
using GraphQL itself
SWAPI
GraphQL : Introspection
{
__type(name: “User”) {
name,
fields {
name,
type {
name
}
}
}
}
{
“data” : {
“__type”: {
“name” : “User”,
“fields” : [
{
“name” : “id”,
“type” : { “name” : “String” }
},
{
“name” : “name”,
“type” : { “name” : “String” }
},
{
“name” : “gender”,
“type” : { “name” : “Boolean” }
},
]
}
}
SWAPI
GraphQL : Arguments
● Arguments allow to pass arguments to your GraphQL
query
{
posts(category:METEOR){
title,
category,
content
}
}
SWAPI
GraphQL : Adding cache
Adding cache not on the GraphQL schema but on data
fetcher.
SWAPI
GraphQL : Several data sourcesSWAPI
GraphQL : Mutations
Creating a specific endpoint on the GraphQL Schema for
a client to ask for data mutation on the backend data
SWAPI
GraphQL : Directives and
Variables
SWAPI
● Variable ability allows to add variable to your queries
● Directive ability provides a way to describe alternate
runtime execution and type validation directly in your
queries
query myQuery($someTest: Boolean) {
experimentalField @skip(if: $someTest)
}
GraphQL usefull links
● http://graphql.org/
● http://facebook.github.io/graphql/
● https://sandbox.learngraphql.com/
● https://learngraphql.com/
● https://code.facebook.com
Relay
Best use of GraphQL for moderns webapps ? Why ? How ?
How relay help us ?
● To create true independents/reusables components.
● To further optimize data fetching.
● Static query check at build time (babel plugin)
● Effortless data mutation (Nope)
https://facebook.github.io/relay/
https://github.com/facebook/relay/
From graph data to components !
Expliquer le mapping de données sur
un composant
Relay container
Relay route
Relay.route
A query targeting an entry point of
our GraphQL endpoint.
Relay.RootContainer
Compose a Relay Route and a
Relay enhanced component.
Relay.container
Wrap a React
component.
Declare needed
data inside a
GraphQL
Fragment
Lets start to compose
Fragment and reusability
Relay compose and solve !
Under data fetching
Over data fetching
Use the best of GraphQL
tl/dr kill the need of ad’hoc endpoints
Under data fetching
Under data fetching
Over data fetching
Solved !
Store ?
Relay graph local cache
Reducing graph request sent to GraphQL endpoint
Reducing graph response
Pushing mutations
Graph Local Cache
Graph Local Cache
GraphQL Relay specification
● Unique ID for every element
● Endpoint to refetch object one by one
● Pagination through connections
○ Unique ID for a connection
○ Unique ID for each cursor in a connection
● Input and output of mutation Unique ID
GraphQL Relay to save the day
GraphQL Relay provide api to help fulfilling these request.
GraphQL Relay live in your GraphQL Endpoint
https://github.com/graphql/graphql-relay-js
Mutation - Welcome to hell
(seriously hardest part of relay)
Mutation
Relay push mutation to server
And ask back as a payload an intersection between what it
need and what changed on the server.
Can mutate local cache optimistically.
Mutation - payload intersection
App State
Binding with app routing
No app state stored only app data
Resources
https://github.com/relayjs/relay-starter-kit
https://code-cartoons.com/a-cartoon-intro-to-facebook-s-
relay-part-1-3ec1a127bca5#.y0x0eivc3
QUESTION(S) ?

More Related Content

What's hot (20)

PDF
GraphQL in an Age of REST
Yos Riady
 
PDF
The Apollo and GraphQL Stack
Sashko Stubailo
 
PDF
GraphQL: Enabling a new generation of API developer tools
Sashko Stubailo
 
PDF
GraphQL across the stack: How everything fits together
Sashko Stubailo
 
PDF
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor
Jon Wong
 
PDF
Graphql
Niv Ben David
 
PPTX
Taking Control of your Data with GraphQL
Vinci Rufus
 
PDF
Better APIs with GraphQL
Josh Price
 
PDF
GraphQL: The Missing Link Between Frontend and Backend Devs
Sashko Stubailo
 
PPTX
An intro to GraphQL
valuebound
 
PDF
How to GraphQL
Tomasz Bak
 
PDF
London React August - GraphQL at The Financial Times - Viktor Charypar
React London Community
 
PPTX
GraphQL Introduction
Serge Huber
 
PDF
GraphQL IndyJS April 2016
Brad Pillow
 
PDF
GraphQL over REST at Reactathon 2018
Sashko Stubailo
 
PDF
REST vs GraphQL
Squareboat
 
PPT
Graphql presentation
Vibhor Grover
 
PDF
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
Hafiz Ismail
 
PDF
Meteor MIT Tech Talk 9/18/14: Designing a New Platform For Modern Apps
Sashko Stubailo
 
PDF
Intro to GraphQL
Rakuten Group, Inc.
 
GraphQL in an Age of REST
Yos Riady
 
The Apollo and GraphQL Stack
Sashko Stubailo
 
GraphQL: Enabling a new generation of API developer tools
Sashko Stubailo
 
GraphQL across the stack: How everything fits together
Sashko Stubailo
 
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor
Jon Wong
 
Graphql
Niv Ben David
 
Taking Control of your Data with GraphQL
Vinci Rufus
 
Better APIs with GraphQL
Josh Price
 
GraphQL: The Missing Link Between Frontend and Backend Devs
Sashko Stubailo
 
An intro to GraphQL
valuebound
 
How to GraphQL
Tomasz Bak
 
London React August - GraphQL at The Financial Times - Viktor Charypar
React London Community
 
GraphQL Introduction
Serge Huber
 
GraphQL IndyJS April 2016
Brad Pillow
 
GraphQL over REST at Reactathon 2018
Sashko Stubailo
 
REST vs GraphQL
Squareboat
 
Graphql presentation
Vibhor Grover
 
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
Hafiz Ismail
 
Meteor MIT Tech Talk 9/18/14: Designing a New Platform For Modern Apps
Sashko Stubailo
 
Intro to GraphQL
Rakuten Group, Inc.
 

Viewers also liked (8)

PDF
React, GraphQL и Relay - вполне себе нормальный компонентный подход (nodkz)
Pavel Chertorogov
 
PDF
Spring.io
Cédric GILLET
 
PDF
Бэкенд, фронтенд — всё смешалось (nodkz)
Pavel Chertorogov
 
PDF
From MEAN to the MERN Stack
Troy Miles
 
PPTX
MERN Presentation, January 2015
Barry Dyck
 
PPTX
GraphQL Relay Introduction
Chen-Tsu Lin
 
PPTX
Introduction to MongoDB
Chun-Kai Wang
 
PDF
reveal.js 3.0.0
Hakim El Hattab
 
React, GraphQL и Relay - вполне себе нормальный компонентный подход (nodkz)
Pavel Chertorogov
 
Spring.io
Cédric GILLET
 
Бэкенд, фронтенд — всё смешалось (nodkz)
Pavel Chertorogov
 
From MEAN to the MERN Stack
Troy Miles
 
MERN Presentation, January 2015
Barry Dyck
 
GraphQL Relay Introduction
Chen-Tsu Lin
 
Introduction to MongoDB
Chun-Kai Wang
 
reveal.js 3.0.0
Hakim El Hattab
 
Ad

Similar to GraphQL + relay (20)

PDF
GraphQL and Relay Modern
Carmel JavaScript Roundabout
 
PDF
GraphQL And Relay Modern
Brad Pillow
 
PDF
GraphQL And Relay Modern
Brad Pillow
 
PPTX
GraphQL API Gateway and microservices
Mohammed Shaban
 
PDF
GraphQL Bangkok meetup 5.0
Tobias Meixner
 
PPTX
GraphQL API Crafts presentation
Sudheer J
 
PDF
GraphQL for Native Apps
Emanuele Di Saverio
 
PDF
GraphQL Fundamentals
Virbhadra Ankalkote
 
PDF
Modern APIs with GraphQL
Taikai
 
PDF
GraphQL - A query language to empower your API consumers (NDC Sydney 2017)
Rob Crowley
 
PPTX
Introduction to GraphQL
Bhargav Anadkat
 
PDF
GraphQL with .NET Core Microservices.pdf
Knoldus Inc.
 
PDF
GraphQL
Deepak Shevani
 
PDF
GraphQL ♥︎ GraphDB
GraphRM
 
PDF
Marco Liberati - Graph analytics
Codemotion
 
PDF
Let's start GraphQL: structure, behavior, and architecture
Andrii Gakhov
 
PDF
PHP, the GraphQL ecosystem and GraphQLite
JEAN-GUILLAUME DUJARDIN
 
PDF
Overview of GraphQL & Clients
Pokai Chang
 
PPTX
Introduction to GraphQL Presentation.pptx
Knoldus Inc.
 
PPTX
Graphql
Girish Talekar
 
GraphQL and Relay Modern
Carmel JavaScript Roundabout
 
GraphQL And Relay Modern
Brad Pillow
 
GraphQL And Relay Modern
Brad Pillow
 
GraphQL API Gateway and microservices
Mohammed Shaban
 
GraphQL Bangkok meetup 5.0
Tobias Meixner
 
GraphQL API Crafts presentation
Sudheer J
 
GraphQL for Native Apps
Emanuele Di Saverio
 
GraphQL Fundamentals
Virbhadra Ankalkote
 
Modern APIs with GraphQL
Taikai
 
GraphQL - A query language to empower your API consumers (NDC Sydney 2017)
Rob Crowley
 
Introduction to GraphQL
Bhargav Anadkat
 
GraphQL with .NET Core Microservices.pdf
Knoldus Inc.
 
GraphQL ♥︎ GraphDB
GraphRM
 
Marco Liberati - Graph analytics
Codemotion
 
Let's start GraphQL: structure, behavior, and architecture
Andrii Gakhov
 
PHP, the GraphQL ecosystem and GraphQLite
JEAN-GUILLAUME DUJARDIN
 
Overview of GraphQL & Clients
Pokai Chang
 
Introduction to GraphQL Presentation.pptx
Knoldus Inc.
 
Ad

Recently uploaded (20)

PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Tally software_Introduction_Presentation
AditiBansal54083
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 

GraphQL + relay