際際滷

際際滷Share a Scribd company logo
Flux to GraphQL
Turadg Aleahmad, Remind
@turadg, @RemindEng
 My company is awesome
 GraphQL, what and why
 How to transition
 Tips and gotchas
Outline
Working to connect every teacher, student and parent
In a study, text-message alerts to parents reduced course failures by 39% and
increased class attendance by 17%.
Over 20 million actively use Remind every month (70% of US public schools)
Over 3.6 billion messages delivered on Remind in 2016
Now: Engineering Manager on Engagement team at Remind
N-1 Led our Web platform and Client Infra team
N-2 Started React at Coursera
N-3 Academia
Turadg Aleahmad
Web team
GraphQL
A query language for your API
Requests
POST a query
Get back JSON
Schema
 Over-fetching for 5yr backwards compatibility
 Client-server misunderstandings (nullability, enums, Swagger lies, etc)
 Under-fetching (without getting a backend dev)
 Ad-hoc batching (graph queries in REST)
 Rails API monolith hard to break apart
Problems we faced
 Every fetch declares exactly what it needs
 Schema is fully typed and enforced
 Client can batch whatever it likes
 Nested data parsing is well specified
 Lightweight graph resolver service abstracts away all the actual services
Why we adopted GraphQL
Apollo
 Developed by dedicated company
 Optimized for ease of use
 Builds on Redux
 Available now and trustable migration
path
 Will keep stealing from Relay
Choosing a stack
Relay
Used by Facebook
Optimized for performance
Heavier to adopt
Relay 1.0 was going to be replaced by
something very different, with no timeline
(Havent looked yet at Relay Modern)
React Flux to GraphQL
How to transition (n=1)
Started as fast rewrite of an Angular app into React with vanilla Flux pattern.
(Summer 2015)
Backbone, with a store for almost every type. CurrentUser, GroupStore, 
No libraries, just a pattern. No constraints.
Lots of actions that were also blocking promises (shortcut).
Starting point
Had two data access patterns for components:
1. Store updates
2. Promise resolution
Add:
3. Apollo client
without breaking the other two.
Goal
1.GraphQL server
2.Isolated GraphQL component
3.GraphQL in legacy actions
4.Component queries updating legacy stores
Stages
GraphQL server
Isolated GraphQL component
Test out developer experience and operations
Chose a single form field to test read/write
Low traffic off in the settings page
Used react-apollo abstraction to contain entirely in component
React Flux to GraphQL
React Flux to GraphQL
Want all our existing data access to resolved by GraphQL
Had to maintain contract of the actions (Flux and promises)
But also update the Apollo state
GraphQL in legacy actions
React Flux to GraphQL
React Flux to GraphQL
Component queries updating legacy stores
Actions were now updating stores and Apollo
Pure GraphQL requests had to manually update stores (localUpdate)
We wanted a way to have legacy stores update when any relevant data came in
by GraphQL
watchQuery fires when any data underlying the query changes
React Flux to GraphQL
Some REST endpoints we havent migrated to GraphQL server yet
Authed User object tricky to move. For push data, no other option.
We dont want to fetch redundantly so we bring that data into Apollo
Have to match the response structure for the query, including __typename
Adapting legacy data into Apollo
React Flux to GraphQL
Tips and Gotchas
As components declare what they need, you need to track what you already
have.
dataIdFromObject is the cache key in Apollos part of the Redux store.
We ended up writing a lint rule to ensure that the key data is always queried
https://github.com/apollographql/eslint-plugin-graphql/pull/50
Cache keys
React Flux to GraphQL
HTTP response headers
GraphQL responds 200 if the resolver returns.
The resolver can gather a lot of errors.
Further complicated by network-level query batching.
Have to write logic for what you used to handle by HTTP error codes.
React Flux to GraphQL
React Flux to GraphQL
Mobile clients in the wild will continue to require REST
Dont want to have multiple paths
We created middleware for REST on top of GraphQL
https://github.com/remind101/rest-graphql
REST client compatibility
 Great with Apollo client
 Just rehydrate the Redux store
 All data needs are declared in visual components
 For security, make sure every request gets a fresh client instance
 Also make sure that instance does not have query batching (CPU leak)
Server rendering
 Adopt in small steps
 Plan far ahead
 Get your schema right
 Be creative
Parting thoughts

More Related Content

What's hot (20)

The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL Stack
Sashko Stubailo
GraphQL across the stack: How everything fits together
GraphQL across the stack: How everything fits togetherGraphQL across the stack: How everything fits together
GraphQL across the stack: How everything fits together
Sashko Stubailo
GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018
Sashko Stubailo
Create flexible react applications using GraphQL API's
Create flexible react applications using GraphQL API'sCreate flexible react applications using GraphQL API's
Create flexible react applications using GraphQL API's
Maurice De Beijer [MVP]
Graphql Intro (Tutorial and Example)
Graphql Intro (Tutorial and Example)Graphql Intro (Tutorial and Example)
Graphql Intro (Tutorial and Example)
Rafael Wilber Kerr
Modular GraphQL with Schema Stitching
Modular GraphQL with Schema StitchingModular GraphQL with Schema Stitching
Modular GraphQL with Schema Stitching
Sashko Stubailo
Raphael Amorim - Scrating React Fiber
Raphael Amorim - Scrating React FiberRaphael Amorim - Scrating React Fiber
Raphael Amorim - Scrating React Fiber
React Conf Brasil
How to GraphQL
How to GraphQLHow to GraphQL
How to GraphQL
Tomasz Bak
Create flexible React applications using GraphQL apis
Create flexible React applications using GraphQL apisCreate flexible React applications using GraphQL apis
Create flexible React applications using GraphQL apis
Maurice De Beijer [MVP]
Adding GraphQL to your existing architecture
Adding GraphQL to your existing architectureAdding GraphQL to your existing architecture
Adding GraphQL to your existing architecture
Sashko Stubailo
Meteor MIT Tech Talk 9/18/14: Designing a New Platform For Modern Apps
Meteor MIT Tech Talk 9/18/14: Designing a New Platform For Modern AppsMeteor MIT Tech Talk 9/18/14: Designing a New Platform For Modern Apps
Meteor MIT Tech Talk 9/18/14: Designing a New Platform For Modern Apps
Sashko Stubailo
React, GraphQL 亳 Relay - 于仗仂仍仆亠 亠弍亠 仆仂仄舒仍仆亶 从仂仄仗仂仆亠仆仆亶 仗仂亟仂亟 (nodkz)
React, GraphQL 亳 Relay - 于仗仂仍仆亠 亠弍亠 仆仂仄舒仍仆亶 从仂仄仗仂仆亠仆仆亶 仗仂亟仂亟 (nodkz)React, GraphQL 亳 Relay - 于仗仂仍仆亠 亠弍亠 仆仂仄舒仍仆亶 从仂仄仗仂仆亠仆仆亶 仗仂亟仂亟 (nodkz)
React, GraphQL 亳 Relay - 于仗仂仍仆亠 亠弍亠 仆仂仄舒仍仆亶 从仂仄仗仂仆亠仆仆亶 仗仂亟仂亟 (nodkz)
Pavel Chertorogov
An intro to GraphQL
An intro to GraphQLAn intro to GraphQL
An intro to GraphQL
valuebound
Graphql
GraphqlGraphql
Graphql
Arnar 坦r Sveinsson
Into to GraphQL
Into to GraphQLInto to GraphQL
Into to GraphQL
shobot
GraphQL With Relay Part Deux
GraphQL With Relay Part DeuxGraphQL With Relay Part Deux
GraphQL With Relay Part Deux
Brad Pillow
Getting started with GraphQL
Getting started with GraphQLGetting started with GraphQL
Getting started with GraphQL
Thiago Colares
Graphql presentation
Graphql presentationGraphql presentation
Graphql presentation
Vibhor Grover
Create GraphQL server with apolloJS
Create GraphQL server with apolloJSCreate GraphQL server with apolloJS
Create GraphQL server with apolloJS
Jonathan Jalouzot
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
Rodrigo Prates
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL Stack
Sashko Stubailo
GraphQL across the stack: How everything fits together
GraphQL across the stack: How everything fits togetherGraphQL across the stack: How everything fits together
GraphQL across the stack: How everything fits together
Sashko Stubailo
GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018
Sashko Stubailo
Create flexible react applications using GraphQL API's
Create flexible react applications using GraphQL API'sCreate flexible react applications using GraphQL API's
Create flexible react applications using GraphQL API's
Maurice De Beijer [MVP]
Graphql Intro (Tutorial and Example)
Graphql Intro (Tutorial and Example)Graphql Intro (Tutorial and Example)
Graphql Intro (Tutorial and Example)
Rafael Wilber Kerr
Modular GraphQL with Schema Stitching
Modular GraphQL with Schema StitchingModular GraphQL with Schema Stitching
Modular GraphQL with Schema Stitching
Sashko Stubailo
Raphael Amorim - Scrating React Fiber
Raphael Amorim - Scrating React FiberRaphael Amorim - Scrating React Fiber
Raphael Amorim - Scrating React Fiber
React Conf Brasil
How to GraphQL
How to GraphQLHow to GraphQL
How to GraphQL
Tomasz Bak
Create flexible React applications using GraphQL apis
Create flexible React applications using GraphQL apisCreate flexible React applications using GraphQL apis
Create flexible React applications using GraphQL apis
Maurice De Beijer [MVP]
Adding GraphQL to your existing architecture
Adding GraphQL to your existing architectureAdding GraphQL to your existing architecture
Adding GraphQL to your existing architecture
Sashko Stubailo
Meteor MIT Tech Talk 9/18/14: Designing a New Platform For Modern Apps
Meteor MIT Tech Talk 9/18/14: Designing a New Platform For Modern AppsMeteor MIT Tech Talk 9/18/14: Designing a New Platform For Modern Apps
Meteor MIT Tech Talk 9/18/14: Designing a New Platform For Modern Apps
Sashko Stubailo
React, GraphQL 亳 Relay - 于仗仂仍仆亠 亠弍亠 仆仂仄舒仍仆亶 从仂仄仗仂仆亠仆仆亶 仗仂亟仂亟 (nodkz)
React, GraphQL 亳 Relay - 于仗仂仍仆亠 亠弍亠 仆仂仄舒仍仆亶 从仂仄仗仂仆亠仆仆亶 仗仂亟仂亟 (nodkz)React, GraphQL 亳 Relay - 于仗仂仍仆亠 亠弍亠 仆仂仄舒仍仆亶 从仂仄仗仂仆亠仆仆亶 仗仂亟仂亟 (nodkz)
React, GraphQL 亳 Relay - 于仗仂仍仆亠 亠弍亠 仆仂仄舒仍仆亶 从仂仄仗仂仆亠仆仆亶 仗仂亟仂亟 (nodkz)
Pavel Chertorogov
An intro to GraphQL
An intro to GraphQLAn intro to GraphQL
An intro to GraphQL
valuebound
Into to GraphQL
Into to GraphQLInto to GraphQL
Into to GraphQL
shobot
GraphQL With Relay Part Deux
GraphQL With Relay Part DeuxGraphQL With Relay Part Deux
GraphQL With Relay Part Deux
Brad Pillow
Getting started with GraphQL
Getting started with GraphQLGetting started with GraphQL
Getting started with GraphQL
Thiago Colares
Graphql presentation
Graphql presentationGraphql presentation
Graphql presentation
Vibhor Grover
Create GraphQL server with apolloJS
Create GraphQL server with apolloJSCreate GraphQL server with apolloJS
Create GraphQL server with apolloJS
Jonathan Jalouzot
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
Rodrigo Prates

Similar to React Flux to GraphQL (20)

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
React Conf Brasil
How easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performanceHow easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performance
Red Hat
apidays LIVE Paris - GraphQL meshes by Jens Neuse
apidays LIVE Paris - GraphQL meshes by Jens Neuseapidays LIVE Paris - GraphQL meshes by Jens Neuse
apidays LIVE Paris - GraphQL meshes by Jens Neuse
apidays
GraphQL.net
GraphQL.netGraphQL.net
GraphQL.net
Tyler Ayers
Redux vs GraphQL
Redux vs GraphQLRedux vs GraphQL
Redux vs GraphQL
Jordon McKoy
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? W...
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? W...apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? W...
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? W...
apidays
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
Phil Wilkins
GraphQL-ify your APIs - Devoxx UK 2021
 GraphQL-ify your APIs - Devoxx UK 2021 GraphQL-ify your APIs - Devoxx UK 2021
GraphQL-ify your APIs - Devoxx UK 2021
Soham Dasgupta
React and GraphQL at Stripe
React and GraphQL at StripeReact and GraphQL at Stripe
React and GraphQL at Stripe
Sashko Stubailo
PyCon Korea - Real World Graphene
PyCon Korea - Real World GraphenePyCon Korea - Real World Graphene
PyCon Korea - Real World Graphene
Marcin Gbala
GraphQL for Native Apps
GraphQL for Native AppsGraphQL for Native Apps
GraphQL for Native Apps
Emanuele Di Saverio
Kotlin REST & GraphQL API
Kotlin REST & GraphQL APIKotlin REST & GraphQL API
Kotlin REST & GraphQL API
Sean O'Brien
GraphQL API Crafts presentation
GraphQL API Crafts presentationGraphQL API Crafts presentation
GraphQL API Crafts presentation
Sudheer J
GraphQL - Missing Link In REST
GraphQL -  Missing Link In RESTGraphQL -  Missing Link In REST
GraphQL - Missing Link In REST
Anubolu Sreekanth
Comprehensive Guide to React Development 2022.pptx
Comprehensive Guide to React Development 2022.pptxComprehensive Guide to React Development 2022.pptx
Comprehensive Guide to React Development 2022.pptx
75waytechnologies
GraphQL research summary
GraphQL research summaryGraphQL research summary
GraphQL research summary
Objectivity
Introduction to Testing GraphQL Presentation
Introduction to Testing GraphQL PresentationIntroduction to Testing GraphQL Presentation
Introduction to Testing GraphQL Presentation
Knoldus Inc.
Testing Graph QL Presentation (Test Automation)
Testing Graph QL Presentation (Test Automation)Testing Graph QL Presentation (Test Automation)
Testing Graph QL Presentation (Test Automation)
Knoldus Inc.
Spring GraphQL
Spring GraphQLSpring GraphQL
Spring GraphQL
VMware Tanzu
GraphQL vs REST_ Choosing the Best API for Shopify Headless Commerce Developm...
GraphQL vs REST_ Choosing the Best API for Shopify Headless Commerce Developm...GraphQL vs REST_ Choosing the Best API for Shopify Headless Commerce Developm...
GraphQL vs REST_ Choosing the Best API for Shopify Headless Commerce Developm...
CartCoders
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
React Conf Brasil
How easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performanceHow easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performance
Red Hat
apidays LIVE Paris - GraphQL meshes by Jens Neuse
apidays LIVE Paris - GraphQL meshes by Jens Neuseapidays LIVE Paris - GraphQL meshes by Jens Neuse
apidays LIVE Paris - GraphQL meshes by Jens Neuse
apidays
Redux vs GraphQL
Redux vs GraphQLRedux vs GraphQL
Redux vs GraphQL
Jordon McKoy
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? W...
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? W...apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? W...
apidays LIVE Australia 2020 - Have your cake and eat it too: GraphQL? REST? W...
apidays
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
Phil Wilkins
GraphQL-ify your APIs - Devoxx UK 2021
 GraphQL-ify your APIs - Devoxx UK 2021 GraphQL-ify your APIs - Devoxx UK 2021
GraphQL-ify your APIs - Devoxx UK 2021
Soham Dasgupta
React and GraphQL at Stripe
React and GraphQL at StripeReact and GraphQL at Stripe
React and GraphQL at Stripe
Sashko Stubailo
PyCon Korea - Real World Graphene
PyCon Korea - Real World GraphenePyCon Korea - Real World Graphene
PyCon Korea - Real World Graphene
Marcin Gbala
Kotlin REST & GraphQL API
Kotlin REST & GraphQL APIKotlin REST & GraphQL API
Kotlin REST & GraphQL API
Sean O'Brien
GraphQL API Crafts presentation
GraphQL API Crafts presentationGraphQL API Crafts presentation
GraphQL API Crafts presentation
Sudheer J
GraphQL - Missing Link In REST
GraphQL -  Missing Link In RESTGraphQL -  Missing Link In REST
GraphQL - Missing Link In REST
Anubolu Sreekanth
Comprehensive Guide to React Development 2022.pptx
Comprehensive Guide to React Development 2022.pptxComprehensive Guide to React Development 2022.pptx
Comprehensive Guide to React Development 2022.pptx
75waytechnologies
GraphQL research summary
GraphQL research summaryGraphQL research summary
GraphQL research summary
Objectivity
Introduction to Testing GraphQL Presentation
Introduction to Testing GraphQL PresentationIntroduction to Testing GraphQL Presentation
Introduction to Testing GraphQL Presentation
Knoldus Inc.
Testing Graph QL Presentation (Test Automation)
Testing Graph QL Presentation (Test Automation)Testing Graph QL Presentation (Test Automation)
Testing Graph QL Presentation (Test Automation)
Knoldus Inc.
GraphQL vs REST_ Choosing the Best API for Shopify Headless Commerce Developm...
GraphQL vs REST_ Choosing the Best API for Shopify Headless Commerce Developm...GraphQL vs REST_ Choosing the Best API for Shopify Headless Commerce Developm...
GraphQL vs REST_ Choosing the Best API for Shopify Headless Commerce Developm...
CartCoders

Recently uploaded (20)

Water Industry Process Automation & Control Monthly - March 2025.pdf
Water Industry Process Automation & Control Monthly - March 2025.pdfWater Industry Process Automation & Control Monthly - March 2025.pdf
Water Industry Process Automation & Control Monthly - March 2025.pdf
Water Industry Process Automation & Control
Power Point Presentation for Electrical Engineering 3-phase.ppt
Power Point Presentation for Electrical Engineering 3-phase.pptPower Point Presentation for Electrical Engineering 3-phase.ppt
Power Point Presentation for Electrical Engineering 3-phase.ppt
Aniket_1415
Cyber Security_ Protecting the Digital World.pptx
Cyber Security_ Protecting the Digital World.pptxCyber Security_ Protecting the Digital World.pptx
Cyber Security_ Protecting the Digital World.pptx
Harshith A S
Mathematics behind machine learning INT255 INT255__Unit 3__PPT-1.pptx
Mathematics behind machine learning INT255 INT255__Unit 3__PPT-1.pptxMathematics behind machine learning INT255 INT255__Unit 3__PPT-1.pptx
Mathematics behind machine learning INT255 INT255__Unit 3__PPT-1.pptx
ppkmurthy2006
04 MAINTENANCE OF CONCRETE PAVEMENTS.ppt
04  MAINTENANCE OF CONCRETE PAVEMENTS.ppt04  MAINTENANCE OF CONCRETE PAVEMENTS.ppt
04 MAINTENANCE OF CONCRETE PAVEMENTS.ppt
sreenath seenu
Introduction to Safety, Health & Environment
Introduction to Safety, Health  & EnvironmentIntroduction to Safety, Health  & Environment
Introduction to Safety, Health & Environment
ssuserc606c7
Piping-and-pipeline-calculations-manual.pdf
Piping-and-pipeline-calculations-manual.pdfPiping-and-pipeline-calculations-manual.pdf
Piping-and-pipeline-calculations-manual.pdf
OMI0721
RAMSES- EDITORIAL SAMPLE FOR DSSPC C.pptx
RAMSES- EDITORIAL SAMPLE FOR DSSPC C.pptxRAMSES- EDITORIAL SAMPLE FOR DSSPC C.pptx
RAMSES- EDITORIAL SAMPLE FOR DSSPC C.pptx
JenTeruel1
Mathematics_behind_machine_learning_INT255.pptx
Mathematics_behind_machine_learning_INT255.pptxMathematics_behind_machine_learning_INT255.pptx
Mathematics_behind_machine_learning_INT255.pptx
ppkmurthy2006
eng funda notes.pdfddddddddddddddddddddddd
eng funda notes.pdfdddddddddddddddddddddddeng funda notes.pdfddddddddddddddddddddddd
eng funda notes.pdfddddddddddddddddddddddd
aayushkumarsinghec22
Integration of Additive Manufacturing (AM) with IoT : A Smart Manufacturing A...
Integration of Additive Manufacturing (AM) with IoT : A Smart Manufacturing A...Integration of Additive Manufacturing (AM) with IoT : A Smart Manufacturing A...
Integration of Additive Manufacturing (AM) with IoT : A Smart Manufacturing A...
ASHISHDESAI85
How to Build a Maze Solving Robot Using Arduino
How to Build a Maze Solving Robot Using ArduinoHow to Build a Maze Solving Robot Using Arduino
How to Build a Maze Solving Robot Using Arduino
CircuitDigest
15. Smart Cities Big Data, Civic Hackers, and the Quest for a New Utopia.pdf
15. Smart Cities Big Data, Civic Hackers, and the Quest for a New Utopia.pdf15. Smart Cities Big Data, Civic Hackers, and the Quest for a New Utopia.pdf
15. Smart Cities Big Data, Civic Hackers, and the Quest for a New Utopia.pdf
NgocThang9
G8 mini project for alcohol detection and engine lock system with GPS tracki...
G8 mini project for  alcohol detection and engine lock system with GPS tracki...G8 mini project for  alcohol detection and engine lock system with GPS tracki...
G8 mini project for alcohol detection and engine lock system with GPS tracki...
sahillanjewar294
GM Meeting 070225 TO 130225 for 2024.pptx
GM Meeting 070225 TO 130225 for 2024.pptxGM Meeting 070225 TO 130225 for 2024.pptx
GM Meeting 070225 TO 130225 for 2024.pptx
crdslalcomumbai
decarbonization steel industry rev1.pptx
decarbonization steel industry rev1.pptxdecarbonization steel industry rev1.pptx
decarbonization steel industry rev1.pptx
gonzalezolabarriaped
Indian Soil Classification System in Geotechnical Engineering
Indian Soil Classification System in Geotechnical EngineeringIndian Soil Classification System in Geotechnical Engineering
Indian Soil Classification System in Geotechnical Engineering
Rajani Vyawahare
Cloud Computing concepts and technologies
Cloud Computing concepts and technologiesCloud Computing concepts and technologies
Cloud Computing concepts and technologies
ssuser4c9444
decarbonization steel industry rev1.pptx
decarbonization steel industry rev1.pptxdecarbonization steel industry rev1.pptx
decarbonization steel industry rev1.pptx
gonzalezolabarriaped
CONTRACTOR ALL RISK INSURANCESAR (1).ppt
CONTRACTOR ALL RISK INSURANCESAR (1).pptCONTRACTOR ALL RISK INSURANCESAR (1).ppt
CONTRACTOR ALL RISK INSURANCESAR (1).ppt
suaktonny
Power Point Presentation for Electrical Engineering 3-phase.ppt
Power Point Presentation for Electrical Engineering 3-phase.pptPower Point Presentation for Electrical Engineering 3-phase.ppt
Power Point Presentation for Electrical Engineering 3-phase.ppt
Aniket_1415
Cyber Security_ Protecting the Digital World.pptx
Cyber Security_ Protecting the Digital World.pptxCyber Security_ Protecting the Digital World.pptx
Cyber Security_ Protecting the Digital World.pptx
Harshith A S
Mathematics behind machine learning INT255 INT255__Unit 3__PPT-1.pptx
Mathematics behind machine learning INT255 INT255__Unit 3__PPT-1.pptxMathematics behind machine learning INT255 INT255__Unit 3__PPT-1.pptx
Mathematics behind machine learning INT255 INT255__Unit 3__PPT-1.pptx
ppkmurthy2006
04 MAINTENANCE OF CONCRETE PAVEMENTS.ppt
04  MAINTENANCE OF CONCRETE PAVEMENTS.ppt04  MAINTENANCE OF CONCRETE PAVEMENTS.ppt
04 MAINTENANCE OF CONCRETE PAVEMENTS.ppt
sreenath seenu
Introduction to Safety, Health & Environment
Introduction to Safety, Health  & EnvironmentIntroduction to Safety, Health  & Environment
Introduction to Safety, Health & Environment
ssuserc606c7
Piping-and-pipeline-calculations-manual.pdf
Piping-and-pipeline-calculations-manual.pdfPiping-and-pipeline-calculations-manual.pdf
Piping-and-pipeline-calculations-manual.pdf
OMI0721
RAMSES- EDITORIAL SAMPLE FOR DSSPC C.pptx
RAMSES- EDITORIAL SAMPLE FOR DSSPC C.pptxRAMSES- EDITORIAL SAMPLE FOR DSSPC C.pptx
RAMSES- EDITORIAL SAMPLE FOR DSSPC C.pptx
JenTeruel1
Mathematics_behind_machine_learning_INT255.pptx
Mathematics_behind_machine_learning_INT255.pptxMathematics_behind_machine_learning_INT255.pptx
Mathematics_behind_machine_learning_INT255.pptx
ppkmurthy2006
eng funda notes.pdfddddddddddddddddddddddd
eng funda notes.pdfdddddddddddddddddddddddeng funda notes.pdfddddddddddddddddddddddd
eng funda notes.pdfddddddddddddddddddddddd
aayushkumarsinghec22
Integration of Additive Manufacturing (AM) with IoT : A Smart Manufacturing A...
Integration of Additive Manufacturing (AM) with IoT : A Smart Manufacturing A...Integration of Additive Manufacturing (AM) with IoT : A Smart Manufacturing A...
Integration of Additive Manufacturing (AM) with IoT : A Smart Manufacturing A...
ASHISHDESAI85
How to Build a Maze Solving Robot Using Arduino
How to Build a Maze Solving Robot Using ArduinoHow to Build a Maze Solving Robot Using Arduino
How to Build a Maze Solving Robot Using Arduino
CircuitDigest
15. Smart Cities Big Data, Civic Hackers, and the Quest for a New Utopia.pdf
15. Smart Cities Big Data, Civic Hackers, and the Quest for a New Utopia.pdf15. Smart Cities Big Data, Civic Hackers, and the Quest for a New Utopia.pdf
15. Smart Cities Big Data, Civic Hackers, and the Quest for a New Utopia.pdf
NgocThang9
G8 mini project for alcohol detection and engine lock system with GPS tracki...
G8 mini project for  alcohol detection and engine lock system with GPS tracki...G8 mini project for  alcohol detection and engine lock system with GPS tracki...
G8 mini project for alcohol detection and engine lock system with GPS tracki...
sahillanjewar294
GM Meeting 070225 TO 130225 for 2024.pptx
GM Meeting 070225 TO 130225 for 2024.pptxGM Meeting 070225 TO 130225 for 2024.pptx
GM Meeting 070225 TO 130225 for 2024.pptx
crdslalcomumbai
decarbonization steel industry rev1.pptx
decarbonization steel industry rev1.pptxdecarbonization steel industry rev1.pptx
decarbonization steel industry rev1.pptx
gonzalezolabarriaped
Indian Soil Classification System in Geotechnical Engineering
Indian Soil Classification System in Geotechnical EngineeringIndian Soil Classification System in Geotechnical Engineering
Indian Soil Classification System in Geotechnical Engineering
Rajani Vyawahare
Cloud Computing concepts and technologies
Cloud Computing concepts and technologiesCloud Computing concepts and technologies
Cloud Computing concepts and technologies
ssuser4c9444
decarbonization steel industry rev1.pptx
decarbonization steel industry rev1.pptxdecarbonization steel industry rev1.pptx
decarbonization steel industry rev1.pptx
gonzalezolabarriaped
CONTRACTOR ALL RISK INSURANCESAR (1).ppt
CONTRACTOR ALL RISK INSURANCESAR (1).pptCONTRACTOR ALL RISK INSURANCESAR (1).ppt
CONTRACTOR ALL RISK INSURANCESAR (1).ppt
suaktonny

React Flux to GraphQL

  • 1. Flux to GraphQL Turadg Aleahmad, Remind @turadg, @RemindEng
  • 2. My company is awesome GraphQL, what and why How to transition Tips and gotchas Outline
  • 3. Working to connect every teacher, student and parent In a study, text-message alerts to parents reduced course failures by 39% and increased class attendance by 17%. Over 20 million actively use Remind every month (70% of US public schools) Over 3.6 billion messages delivered on Remind in 2016
  • 4. Now: Engineering Manager on Engagement team at Remind N-1 Led our Web platform and Client Infra team N-2 Started React at Coursera N-3 Academia Turadg Aleahmad
  • 9. Over-fetching for 5yr backwards compatibility Client-server misunderstandings (nullability, enums, Swagger lies, etc) Under-fetching (without getting a backend dev) Ad-hoc batching (graph queries in REST) Rails API monolith hard to break apart Problems we faced
  • 10. Every fetch declares exactly what it needs Schema is fully typed and enforced Client can batch whatever it likes Nested data parsing is well specified Lightweight graph resolver service abstracts away all the actual services Why we adopted GraphQL
  • 11. Apollo Developed by dedicated company Optimized for ease of use Builds on Redux Available now and trustable migration path Will keep stealing from Relay Choosing a stack Relay Used by Facebook Optimized for performance Heavier to adopt Relay 1.0 was going to be replaced by something very different, with no timeline (Havent looked yet at Relay Modern)
  • 14. Started as fast rewrite of an Angular app into React with vanilla Flux pattern. (Summer 2015) Backbone, with a store for almost every type. CurrentUser, GroupStore, No libraries, just a pattern. No constraints. Lots of actions that were also blocking promises (shortcut). Starting point
  • 15. Had two data access patterns for components: 1. Store updates 2. Promise resolution Add: 3. Apollo client without breaking the other two. Goal
  • 16. 1.GraphQL server 2.Isolated GraphQL component 3.GraphQL in legacy actions 4.Component queries updating legacy stores Stages
  • 18. Isolated GraphQL component Test out developer experience and operations Chose a single form field to test read/write Low traffic off in the settings page Used react-apollo abstraction to contain entirely in component
  • 21. Want all our existing data access to resolved by GraphQL Had to maintain contract of the actions (Flux and promises) But also update the Apollo state GraphQL in legacy actions
  • 24. Component queries updating legacy stores Actions were now updating stores and Apollo Pure GraphQL requests had to manually update stores (localUpdate) We wanted a way to have legacy stores update when any relevant data came in by GraphQL watchQuery fires when any data underlying the query changes
  • 26. Some REST endpoints we havent migrated to GraphQL server yet Authed User object tricky to move. For push data, no other option. We dont want to fetch redundantly so we bring that data into Apollo Have to match the response structure for the query, including __typename Adapting legacy data into Apollo
  • 29. As components declare what they need, you need to track what you already have. dataIdFromObject is the cache key in Apollos part of the Redux store. We ended up writing a lint rule to ensure that the key data is always queried https://github.com/apollographql/eslint-plugin-graphql/pull/50 Cache keys
  • 31. HTTP response headers GraphQL responds 200 if the resolver returns. The resolver can gather a lot of errors. Further complicated by network-level query batching. Have to write logic for what you used to handle by HTTP error codes.
  • 34. Mobile clients in the wild will continue to require REST Dont want to have multiple paths We created middleware for REST on top of GraphQL https://github.com/remind101/rest-graphql REST client compatibility
  • 35. Great with Apollo client Just rehydrate the Redux store All data needs are declared in visual components For security, make sure every request gets a fresh client instance Also make sure that instance does not have query batching (CPU leak) Server rendering
  • 36. Adopt in small steps Plan far ahead Get your schema right Be creative Parting thoughts