SlideShare una empresa de Scribd logo
1 de 51
Descargar para leer sin conexión
React and GraphQL
at Stripe
Sashko Stubailo
Engineering Manager, Dashboard Discovery
@stubailo
O V E R V I E W
1. How GraphQL fits into the modern
product development stack
2. Novel tools that we built at Stripe
3. Unexpected benefits we're excited about
M Y B A C K G R O U N D
1. Since 2015: Worked on open source GraphQL
tooling at Apollo: Apollo Client, Server, etc
2. Since late 2018: Engineer on Stripe dashboard
platform team, helped build out GraphQL
implementation
Important note: Everything I'm about to present was
a team effort! It takes a village to build these things.
Developing in the
Stripe Dashboard
• Lots of product teams
contributing at once
• Needs to work together as a
unified whole
S T R I P E ' S W E B S TA C K
• React
• Flow
• Jest
• Webpack
• Ruby
• GraphQL and Apollo (new)
GraphQL: Define a schema instead of a list of endpoints
/authors
/authors/1
/posts
/posts/1
From separate API requests to one GraphQL query
Fetch as few or as many fields
as you want in one query, and
traverse between types
Queries are sent over POST
requests to a single /graphql
endpoint
Simple front-end data fetching
How do we make product
development better?
P R O D U C T D E V E L O P M E N T
Frontend
API
Backend
P R O D U C T D E V E L O P M E N T
Components
API
Backend
State
management
Tests
Backend
Component
explorer
Editor
CI
Monitoring
Type
generation
P R O D U C T D E V E L O P M E N T
Components
API
Backend
State
management
Tests
Backend
Component
explorer
Editor
CI
Monitoring
Type
generation
The most valuable systems are those that can
tie in to all of these aspects of development.
Example: UI component systems
P R O D U C T D E V E L O P M E N T
Components
GraphQL API
Backend
Apollo
Tests
Backend
Component
explorer
Editor
CI
Monitoring
Type
generation
P R O D U C T D E V E L O P M E N T
Components
GraphQL API
Backend
Apollo
Tests
Backend
Component
explorer
Editor
CI
Monitoring
Type
generation
GQL
GQL
GQL
GQL
GQL
GQL
GQL
Why does GraphQL have such a big impact?
The schema defines capabilities Queries define data requirements
Why does GraphQL have such a big impact?
Area GraphQL's benefit
Frontend state Sophisticated data loading and management libraries
API Incremental schema changes without versioning
Monitoring Track individual field usage
Tests Easy mocking
Frontend types Static types per-query
GraphQL contributes to every part of the workflow:
Tools we've built at Stripe:
Data mocking
Why mocking?
Write unit tests and examples
without having to call a real API
• Faster, more resilient tests
• Possible to develop components
before backend is built
• Easy to generate edge case
states
Frontend
Fake API
GraphQL makes mocking easy
We can generate mocks automatically from a schema and query.
Code snippet with graphql-tools:
Problem: What about edge cases?
A globally mocked schema isn't well suited to test...
Error states
Long lists
Loading indicators
Counting
number of
requests
Per-request
mocking
Allows you to specify
edge cases for this test,
but now you lose the
benefits of schema-
based mocking.
(Example from the
Apollo docs)
Schema mocking
with overrides
Best of both worlds:
Automatic mocks for
general testing, and the
ability to override specifics
for a single test.
E X A M P L E S : S E T T I N G U P G L O B A L M O C K S
This will allow most
components to be
rendered without any
custom mocks at all.
E X A M P L E : D E F A U LT M O C K S
In this example, we're just trying to check if the component renders
correctly. The specific data isn't important, so we don't need to
specify anything.
E X A M P L E : O V E R R I D I N G F I E L D S
In this example, we want
to assert for the presence
of specific values in the
rendered component.
We wouldn't want to rely
on global mocks having
those specific values, so
we specify them in the
test.
M O C K F O R L O A D I N G / E R R O R S TAT E S
We've also added helpers for a very common type of edge case:
Errors and loading state.
S P Y I N G O N
M U TAT I O N S
Submitting a
form and
checking that it
succeeded
O N E M O R E T H I N G : G R A P H Q L M O C K S I N O U R C O M P O N E N T S Y S T E M
We have an internal prototyping environment called SailPen, which
Jay Divock presented at DublinJS a few months ago. It also now
supports GraphQL mocking!
Tools we've built at Stripe:
Schema validation
Collaborating on an API
You shouldn't have to be aware of the larger context when making a
small, focused API change
We need guard rails to be able to easily evolve the schema without
introducing breakages
Schema guard rails
To reduce the probability of breakages related from schema
changes, we:
1. Generate a schema.graphql file and check it in to the monorepo
2. Generate Flow types for every query with apollo-codegen
3. Run a backwards compatibility checker in CI
S C H E M A . G R A P H Q L F I L E
This file encodes the current state of the schema, and is
automatically generated and checked in from the API code.
Generating Flow types
apollo-codegen to generate Flow types for each query, mutation,
and fragment.
Q U E R Y W R A P P E R B R I N G S T H E T Y P E S T O G E T H E R
Q U E R Y W R A P P E R
Backwards compatibility checker
It's not enough to make sure that the current frontend is compatible
with the current backend in the monorepo, since there might be
people who haven't refreshed their frontend in a while.
How do we make breaking changes?
Sometimes, you just don't want a field anymore, and you've verified
that nobody is using it anymore.
You can use a two step process to make a change in this case:
1. Mark as deprecated, merge
2. Delete, merge
Note: Not yet ideal for things like modifications to an existing field.
Tools we've built at Stripe:
Monitoring
What makes GraphQL different?
The URL is no longer
meaningful, since all GraphQL
requests go to a single /graphql
path
Important information like the
query name and fields are
hidden in the POST request
body, and need to be extracted
GraphQL-specific metadata
We extract the operation name for logging and charts.
Query ownership
We assign team owners to queries so that errors get routed to the
team whose feature is broken.
Query ownership
We assign team owners to queries so that errors get routed to the
team whose feature is broken.
Benefits we've seen since
adopting GraphQL
Commonly quoted benefits
As seen on graphql.org and
apollographql.com:
• Reduced overfetching
• Self-documenting, strongly typed
schema
• Great developer tools
But there are more benefits that
weren't mentioned there that really
stood out to me at Stripe.
Image from graphql.org
B E N E F I T S T O H I G H L I G H T :
1. Great community tools and docs
2. Easy to add and remove fields from the
schema
3. Localized code changes and static types
Great community tools and docs
• Apollo Client for data fetching
• Apollo Codegen for Flow type generation
• graphql-tools for mocking
We're proud of the internal tooling we've built, but every new tool
we built in-house is something to maintain
GraphQL's well-specified nature allows these tools to be broadly
useful to many organizations
Great community tools and docs
We can leverage existing docs, and growing popularity of GraphQL,
to onboard new developers faster than with custom internal tools
Easy to add and remove fields
• We can implement things just the way we want them
• Easy to iterate on the schema later if we didn't get it right the
first time
• Low cost to having unused fields
Eliminating the field/endpoint tradeoff: In REST, 3 places to add new
data, each with tradeoffs:
1. A new endpoint
2. A new field on an existing endpoint
3. Front-end data transformation
GraphQL eliminates this tradeoff - you can always just add a field!
Easy to add and remove fields
Localized code changes and static types
• Easier to review code
• Fewer unintentional
side effects
• Faster to modify one
component
C O N C L U S I O N
1. GraphQL can make data-related tooling work together
across the stack
2. We're excited about some new tools we've built internally
3. GraphQL had additional unforeseen benefits for product
development velocity
Any questions about the talk or GraphQL in general?
Also, we're hiring at Stripe, please reach out!
Sashko Stubailo, @stubailo on Twitter

Más contenido relacionado

La actualidad más candente

API Gateway Use Cases​ for Kubernetes​
API Gateway Use Cases​ for Kubernetes​API Gateway Use Cases​ for Kubernetes​
API Gateway Use Cases​ for Kubernetes​NGINX, Inc.
 
APIConnect Security Best Practice
APIConnect Security Best PracticeAPIConnect Security Best Practice
APIConnect Security Best PracticeShiu-Fun Poon
 
The Architecture of an API Platform
The Architecture of an API PlatformThe Architecture of an API Platform
The Architecture of an API PlatformJohannes Ridderstedt
 
apidays Paris 2022 - The 12 Facets of the OpenAPI Specification, Steve Sfartz...
apidays Paris 2022 - The 12 Facets of the OpenAPI Specification, Steve Sfartz...apidays Paris 2022 - The 12 Facets of the OpenAPI Specification, Steve Sfartz...
apidays Paris 2022 - The 12 Facets of the OpenAPI Specification, Steve Sfartz...apidays
 
K8s on AWS - Introducing Amazon EKS
K8s on AWS - Introducing Amazon EKSK8s on AWS - Introducing Amazon EKS
K8s on AWS - Introducing Amazon EKSAmazon Web Services
 
Distributed Tracing with Jaeger
Distributed Tracing with JaegerDistributed Tracing with Jaeger
Distributed Tracing with JaegerInho Kang
 
Openshift serverless Solution
Openshift serverless SolutionOpenshift serverless Solution
Openshift serverless SolutionRyan ZhangCheng
 
Kubernetes or OpenShift - choosing your container platform for Dev and Ops
Kubernetes or OpenShift - choosing your container platform for Dev and OpsKubernetes or OpenShift - choosing your container platform for Dev and Ops
Kubernetes or OpenShift - choosing your container platform for Dev and OpsTomasz Cholewa
 
Kubernetes Networking | Kubernetes Services, Pods & Ingress Networks | Kubern...
Kubernetes Networking | Kubernetes Services, Pods & Ingress Networks | Kubern...Kubernetes Networking | Kubernetes Services, Pods & Ingress Networks | Kubern...
Kubernetes Networking | Kubernetes Services, Pods & Ingress Networks | Kubern...Edureka!
 
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCDKubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCDSunnyvale
 
apidays Paris 2022 - API design best practices, Ryan Clifford & Ros Bennis, F...
apidays Paris 2022 - API design best practices, Ryan Clifford & Ros Bennis, F...apidays Paris 2022 - API design best practices, Ryan Clifford & Ros Bennis, F...
apidays Paris 2022 - API design best practices, Ryan Clifford & Ros Bennis, F...apidays
 
stupid-simple-kubernetes-final.pdf
stupid-simple-kubernetes-final.pdfstupid-simple-kubernetes-final.pdf
stupid-simple-kubernetes-final.pdfDaniloQueirozMota
 
Istio : Service Mesh
Istio : Service MeshIstio : Service Mesh
Istio : Service MeshKnoldus Inc.
 
Api-First service design
Api-First service designApi-First service design
Api-First service designStefaan Ponnet
 
Kubernetes Networking
Kubernetes NetworkingKubernetes Networking
Kubernetes NetworkingCJ Cullen
 
Gitops: a new paradigm for software defined operations
Gitops: a new paradigm for software defined operationsGitops: a new paradigm for software defined operations
Gitops: a new paradigm for software defined operationsMariano Cunietti
 

La actualidad más candente (20)

API Gateway Use Cases​ for Kubernetes​
API Gateway Use Cases​ for Kubernetes​API Gateway Use Cases​ for Kubernetes​
API Gateway Use Cases​ for Kubernetes​
 
Prometheus monitoring
Prometheus monitoringPrometheus monitoring
Prometheus monitoring
 
APIConnect Security Best Practice
APIConnect Security Best PracticeAPIConnect Security Best Practice
APIConnect Security Best Practice
 
The Architecture of an API Platform
The Architecture of an API PlatformThe Architecture of an API Platform
The Architecture of an API Platform
 
apidays Paris 2022 - The 12 Facets of the OpenAPI Specification, Steve Sfartz...
apidays Paris 2022 - The 12 Facets of the OpenAPI Specification, Steve Sfartz...apidays Paris 2022 - The 12 Facets of the OpenAPI Specification, Steve Sfartz...
apidays Paris 2022 - The 12 Facets of the OpenAPI Specification, Steve Sfartz...
 
K8s on AWS - Introducing Amazon EKS
K8s on AWS - Introducing Amazon EKSK8s on AWS - Introducing Amazon EKS
K8s on AWS - Introducing Amazon EKS
 
Distributed Tracing with Jaeger
Distributed Tracing with JaegerDistributed Tracing with Jaeger
Distributed Tracing with Jaeger
 
Openshift serverless Solution
Openshift serverless SolutionOpenshift serverless Solution
Openshift serverless Solution
 
Kubernetes or OpenShift - choosing your container platform for Dev and Ops
Kubernetes or OpenShift - choosing your container platform for Dev and OpsKubernetes or OpenShift - choosing your container platform for Dev and Ops
Kubernetes or OpenShift - choosing your container platform for Dev and Ops
 
Gitops Hands On
Gitops Hands OnGitops Hands On
Gitops Hands On
 
Kubernetes Networking | Kubernetes Services, Pods & Ingress Networks | Kubern...
Kubernetes Networking | Kubernetes Services, Pods & Ingress Networks | Kubern...Kubernetes Networking | Kubernetes Services, Pods & Ingress Networks | Kubern...
Kubernetes Networking | Kubernetes Services, Pods & Ingress Networks | Kubern...
 
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCDKubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCD
 
apidays Paris 2022 - API design best practices, Ryan Clifford & Ros Bennis, F...
apidays Paris 2022 - API design best practices, Ryan Clifford & Ros Bennis, F...apidays Paris 2022 - API design best practices, Ryan Clifford & Ros Bennis, F...
apidays Paris 2022 - API design best practices, Ryan Clifford & Ros Bennis, F...
 
stupid-simple-kubernetes-final.pdf
stupid-simple-kubernetes-final.pdfstupid-simple-kubernetes-final.pdf
stupid-simple-kubernetes-final.pdf
 
Istio : Service Mesh
Istio : Service MeshIstio : Service Mesh
Istio : Service Mesh
 
Amazon API Gateway
Amazon API GatewayAmazon API Gateway
Amazon API Gateway
 
Api-First service design
Api-First service designApi-First service design
Api-First service design
 
Kubernetes Networking
Kubernetes NetworkingKubernetes Networking
Kubernetes Networking
 
Effective API Design
Effective API DesignEffective API Design
Effective API Design
 
Gitops: a new paradigm for software defined operations
Gitops: a new paradigm for software defined operationsGitops: a new paradigm for software defined operations
Gitops: a new paradigm for software defined operations
 

Similar a React and GraphQL at Stripe

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 over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018Sashko Stubailo
 
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 performanceLuca Mattia Ferrari
 
Create GraphQL server with apolloJS
Create GraphQL server with apolloJSCreate GraphQL server with apolloJS
Create GraphQL server with apolloJSJonathan Jalouzot
 
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...apidays
 
James Baxley - Statically typing your GraphQL app
James Baxley - Statically typing your GraphQL appJames Baxley - Statically typing your GraphQL app
James Baxley - Statically typing your GraphQL appReact Conf Brasil
 
GraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsGraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsSashko Stubailo
 
apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...
apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...
apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...apidays
 
Serverless GraphQL for Product Developers
Serverless GraphQL for Product DevelopersServerless GraphQL for Product Developers
Serverless GraphQL for Product DevelopersSashko Stubailo
 
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 2021Soham Dasgupta
 
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 togetherSashko Stubailo
 
Agile Data Science on Greenplum Using Airflow - Greenplum Summit 2019
Agile Data Science on Greenplum Using Airflow - Greenplum Summit 2019Agile Data Science on Greenplum Using Airflow - Greenplum Summit 2019
Agile Data Science on Greenplum Using Airflow - Greenplum Summit 2019VMware Tanzu
 
Graphql presentation
Graphql presentationGraphql presentation
Graphql presentationVibhor Grover
 
PyCon Korea - Real World Graphene
PyCon Korea - Real World GraphenePyCon Korea - Real World Graphene
PyCon Korea - Real World GrapheneMarcin Gębala
 
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...Kaxil Naik
 
How to use apolloJS on React ?
How to use apolloJS on React ?How to use apolloJS on React ?
How to use apolloJS on React ?Jonathan Jalouzot
 
APIdays Paris 2019 - Maintain & Evolve a Public GraphQL API by Aurélien Davi...
APIdays Paris 2019 - Maintain & Evolve a Public  GraphQL API by Aurélien Davi...APIdays Paris 2019 - Maintain & Evolve a Public  GraphQL API by Aurélien Davi...
APIdays Paris 2019 - Maintain & Evolve a Public GraphQL API by Aurélien Davi...apidays
 

Similar a React and GraphQL at Stripe (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
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL Stack
 
GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018GraphQL over REST at Reactathon 2018
GraphQL over REST at Reactathon 2018
 
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
 
Create GraphQL server with apolloJS
Create GraphQL server with apolloJSCreate GraphQL server with apolloJS
Create GraphQL server with apolloJS
 
GraphQL for Native Apps
GraphQL for Native AppsGraphQL for Native Apps
GraphQL for Native Apps
 
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
 
James Baxley - Statically typing your GraphQL app
James Baxley - Statically typing your GraphQL appJames Baxley - Statically typing your GraphQL app
James Baxley - Statically typing your GraphQL app
 
GraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsGraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer tools
 
apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...
apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...
apidays LIVE Australia - Have your cake and eat it too: GraphQL? REST? Why no...
 
Serverless GraphQL for Product Developers
Serverless GraphQL for Product DevelopersServerless GraphQL for Product Developers
Serverless GraphQL for Product Developers
 
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
 
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
 
Agile Data Science on Greenplum Using Airflow - Greenplum Summit 2019
Agile Data Science on Greenplum Using Airflow - Greenplum Summit 2019Agile Data Science on Greenplum Using Airflow - Greenplum Summit 2019
Agile Data Science on Greenplum Using Airflow - Greenplum Summit 2019
 
Graphql presentation
Graphql presentationGraphql presentation
Graphql presentation
 
PyCon Korea - Real World Graphene
PyCon Korea - Real World GraphenePyCon Korea - Real World Graphene
PyCon Korea - Real World Graphene
 
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...
 
How to use apolloJS on React ?
How to use apolloJS on React ?How to use apolloJS on React ?
How to use apolloJS on React ?
 
Graphql usage
Graphql usageGraphql usage
Graphql usage
 
APIdays Paris 2019 - Maintain & Evolve a Public GraphQL API by Aurélien Davi...
APIdays Paris 2019 - Maintain & Evolve a Public  GraphQL API by Aurélien Davi...APIdays Paris 2019 - Maintain & Evolve a Public  GraphQL API by Aurélien Davi...
APIdays Paris 2019 - Maintain & Evolve a Public GraphQL API by Aurélien Davi...
 

Más de Sashko Stubailo

Standing out as a new grad candidate
Standing out as a new grad candidateStanding out as a new grad candidate
Standing out as a new grad candidateSashko Stubailo
 
Modular GraphQL with Schema Stitching
Modular GraphQL with Schema StitchingModular GraphQL with Schema Stitching
Modular GraphQL with Schema StitchingSashko Stubailo
 
Adding GraphQL to your existing architecture
Adding GraphQL to your existing architectureAdding GraphQL to your existing architecture
Adding GraphQL to your existing architectureSashko Stubailo
 
Why UI developers love GraphQL
Why UI developers love GraphQLWhy UI developers love GraphQL
Why UI developers love GraphQLSashko Stubailo
 
GraphQL: The Missing Link Between Frontend and Backend Devs
GraphQL: The Missing Link Between Frontend and Backend DevsGraphQL: The Missing Link Between Frontend and Backend Devs
GraphQL: The Missing Link Between Frontend and Backend DevsSashko 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 AppsSashko Stubailo
 

Más de Sashko Stubailo (6)

Standing out as a new grad candidate
Standing out as a new grad candidateStanding out as a new grad candidate
Standing out as a new grad candidate
 
Modular GraphQL with Schema Stitching
Modular GraphQL with Schema StitchingModular GraphQL with Schema Stitching
Modular GraphQL with Schema Stitching
 
Adding GraphQL to your existing architecture
Adding GraphQL to your existing architectureAdding GraphQL to your existing architecture
Adding GraphQL to your existing architecture
 
Why UI developers love GraphQL
Why UI developers love GraphQLWhy UI developers love GraphQL
Why UI developers love GraphQL
 
GraphQL: The Missing Link Between Frontend and Backend Devs
GraphQL: The Missing Link Between Frontend and Backend DevsGraphQL: The Missing Link Between Frontend and Backend Devs
GraphQL: The Missing Link Between Frontend and Backend Devs
 
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
 

Último

Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 

Último (20)

Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 

React and GraphQL at Stripe

  • 1. React and GraphQL at Stripe Sashko Stubailo Engineering Manager, Dashboard Discovery @stubailo
  • 2. O V E R V I E W 1. How GraphQL fits into the modern product development stack 2. Novel tools that we built at Stripe 3. Unexpected benefits we're excited about
  • 3. M Y B A C K G R O U N D 1. Since 2015: Worked on open source GraphQL tooling at Apollo: Apollo Client, Server, etc 2. Since late 2018: Engineer on Stripe dashboard platform team, helped build out GraphQL implementation Important note: Everything I'm about to present was a team effort! It takes a village to build these things.
  • 4. Developing in the Stripe Dashboard • Lots of product teams contributing at once • Needs to work together as a unified whole
  • 5. S T R I P E ' S W E B S TA C K • React • Flow • Jest • Webpack • Ruby • GraphQL and Apollo (new)
  • 6. GraphQL: Define a schema instead of a list of endpoints /authors /authors/1 /posts /posts/1
  • 7. From separate API requests to one GraphQL query Fetch as few or as many fields as you want in one query, and traverse between types Queries are sent over POST requests to a single /graphql endpoint
  • 9. How do we make product development better?
  • 10. P R O D U C T D E V E L O P M E N T Frontend API Backend
  • 11. P R O D U C T D E V E L O P M E N T Components API Backend State management Tests Backend Component explorer Editor CI Monitoring Type generation
  • 12. P R O D U C T D E V E L O P M E N T Components API Backend State management Tests Backend Component explorer Editor CI Monitoring Type generation The most valuable systems are those that can tie in to all of these aspects of development. Example: UI component systems
  • 13. P R O D U C T D E V E L O P M E N T Components GraphQL API Backend Apollo Tests Backend Component explorer Editor CI Monitoring Type generation
  • 14. P R O D U C T D E V E L O P M E N T Components GraphQL API Backend Apollo Tests Backend Component explorer Editor CI Monitoring Type generation GQL GQL GQL GQL GQL GQL GQL
  • 15. Why does GraphQL have such a big impact? The schema defines capabilities Queries define data requirements
  • 16. Why does GraphQL have such a big impact? Area GraphQL's benefit Frontend state Sophisticated data loading and management libraries API Incremental schema changes without versioning Monitoring Track individual field usage Tests Easy mocking Frontend types Static types per-query GraphQL contributes to every part of the workflow:
  • 17. Tools we've built at Stripe: Data mocking
  • 18. Why mocking? Write unit tests and examples without having to call a real API • Faster, more resilient tests • Possible to develop components before backend is built • Easy to generate edge case states Frontend Fake API
  • 19. GraphQL makes mocking easy We can generate mocks automatically from a schema and query. Code snippet with graphql-tools:
  • 20. Problem: What about edge cases? A globally mocked schema isn't well suited to test... Error states Long lists Loading indicators Counting number of requests
  • 21. Per-request mocking Allows you to specify edge cases for this test, but now you lose the benefits of schema- based mocking. (Example from the Apollo docs)
  • 22. Schema mocking with overrides Best of both worlds: Automatic mocks for general testing, and the ability to override specifics for a single test.
  • 23. E X A M P L E S : S E T T I N G U P G L O B A L M O C K S This will allow most components to be rendered without any custom mocks at all.
  • 24. E X A M P L E : D E F A U LT M O C K S In this example, we're just trying to check if the component renders correctly. The specific data isn't important, so we don't need to specify anything.
  • 25. E X A M P L E : O V E R R I D I N G F I E L D S In this example, we want to assert for the presence of specific values in the rendered component. We wouldn't want to rely on global mocks having those specific values, so we specify them in the test.
  • 26. M O C K F O R L O A D I N G / E R R O R S TAT E S We've also added helpers for a very common type of edge case: Errors and loading state.
  • 27. S P Y I N G O N M U TAT I O N S Submitting a form and checking that it succeeded
  • 28. O N E M O R E T H I N G : G R A P H Q L M O C K S I N O U R C O M P O N E N T S Y S T E M We have an internal prototyping environment called SailPen, which Jay Divock presented at DublinJS a few months ago. It also now supports GraphQL mocking!
  • 29. Tools we've built at Stripe: Schema validation
  • 30. Collaborating on an API You shouldn't have to be aware of the larger context when making a small, focused API change We need guard rails to be able to easily evolve the schema without introducing breakages
  • 31. Schema guard rails To reduce the probability of breakages related from schema changes, we: 1. Generate a schema.graphql file and check it in to the monorepo 2. Generate Flow types for every query with apollo-codegen 3. Run a backwards compatibility checker in CI
  • 32. S C H E M A . G R A P H Q L F I L E This file encodes the current state of the schema, and is automatically generated and checked in from the API code.
  • 33. Generating Flow types apollo-codegen to generate Flow types for each query, mutation, and fragment.
  • 34. Q U E R Y W R A P P E R B R I N G S T H E T Y P E S T O G E T H E R
  • 35. Q U E R Y W R A P P E R
  • 36. Backwards compatibility checker It's not enough to make sure that the current frontend is compatible with the current backend in the monorepo, since there might be people who haven't refreshed their frontend in a while.
  • 37. How do we make breaking changes? Sometimes, you just don't want a field anymore, and you've verified that nobody is using it anymore. You can use a two step process to make a change in this case: 1. Mark as deprecated, merge 2. Delete, merge Note: Not yet ideal for things like modifications to an existing field.
  • 38. Tools we've built at Stripe: Monitoring
  • 39. What makes GraphQL different? The URL is no longer meaningful, since all GraphQL requests go to a single /graphql path Important information like the query name and fields are hidden in the POST request body, and need to be extracted
  • 40. GraphQL-specific metadata We extract the operation name for logging and charts.
  • 41. Query ownership We assign team owners to queries so that errors get routed to the team whose feature is broken.
  • 42. Query ownership We assign team owners to queries so that errors get routed to the team whose feature is broken.
  • 43. Benefits we've seen since adopting GraphQL
  • 44. Commonly quoted benefits As seen on graphql.org and apollographql.com: • Reduced overfetching • Self-documenting, strongly typed schema • Great developer tools But there are more benefits that weren't mentioned there that really stood out to me at Stripe. Image from graphql.org
  • 45. B E N E F I T S T O H I G H L I G H T : 1. Great community tools and docs 2. Easy to add and remove fields from the schema 3. Localized code changes and static types
  • 46. Great community tools and docs • Apollo Client for data fetching • Apollo Codegen for Flow type generation • graphql-tools for mocking We're proud of the internal tooling we've built, but every new tool we built in-house is something to maintain GraphQL's well-specified nature allows these tools to be broadly useful to many organizations
  • 47. Great community tools and docs We can leverage existing docs, and growing popularity of GraphQL, to onboard new developers faster than with custom internal tools
  • 48. Easy to add and remove fields • We can implement things just the way we want them • Easy to iterate on the schema later if we didn't get it right the first time • Low cost to having unused fields
  • 49. Eliminating the field/endpoint tradeoff: In REST, 3 places to add new data, each with tradeoffs: 1. A new endpoint 2. A new field on an existing endpoint 3. Front-end data transformation GraphQL eliminates this tradeoff - you can always just add a field! Easy to add and remove fields
  • 50. Localized code changes and static types • Easier to review code • Fewer unintentional side effects • Faster to modify one component
  • 51. C O N C L U S I O N 1. GraphQL can make data-related tooling work together across the stack 2. We're excited about some new tools we've built internally 3. GraphQL had additional unforeseen benefits for product development velocity Any questions about the talk or GraphQL in general? Also, we're hiring at Stripe, please reach out! Sashko Stubailo, @stubailo on Twitter