Adopting GraphQL in an Enterprise

Rate this content
Bookmark

FAQ

Challenges included overfetching data from REST APIs, inconsistent integration experiences, and difficulties with versioned APIs.

The speaker is Shruti Kapoor, a senior software engineer at PayPal.

The main topic is adopting GraphQL in an enterprise setting.

PayPal adopted GraphQL to solve problems such as overfetching data, inconsistent API integration experiences, and the challenges associated with versioned APIs.

GraphQL improved the developer experience by reducing data overfetching, providing a uniform API integration experience, and increasing collaboration between frontend and backend teams.

One approach is to use GraphQL as an orchestration layer between the frontend and existing REST APIs.

Benefits included smaller payloads, easier deprecation of fields, detailed analytics, and improved collaboration between frontend and backend teams.

Companies should start with a low-impact application, avoid one-to-one mapping of REST to GraphQL, and establish a schema contract early on.

Most frontend applications now default to using GraphQL, and the company is moving towards a federated, unified graph approach.

Ongoing challenges include caching, error mapping, and schema unification across different repositories.

Shruti Kapoor
Shruti Kapoor
32 min
08 Dec, 2021

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Today's Talk is about adopting GraphQL in an enterprise. It discusses the challenges of using REST APIs and the benefits of GraphQL. The Talk explores different approaches to adopting GraphQL, including coexistence with REST APIs. It emphasizes the power of GraphQL and provides tips for successful adoption. Overall, the Talk highlights the advantages of GraphQL in terms of efficiency, collaboration, and control over APIs.
Available in Español: Adoptando GraphQL en una Empresa

1. Introduction to Adopting GraphQL in an Enterprise

Short description:

Today, I'm going to be talking about adopting GraphQL in an enterprise. We'll discuss the reasons why GraphQL is a good technology for an enterprise, our experience of adopting GraphQL in PayPal, the challenges we faced, best practices we adopted, and how to get started with GraphQL. I'm Shruti Kapoor, a senior software engineer at PayPal. Follow me on Twitter at Shruti Kapoor08 or Twitch at twitch.tv/ShrutiKapoor for live streaming sessions. When I started at PayPal, I had no experience with GraphQL, but we decided to use it as the frontend layer for a NodeJS app consuming REST APIs. The Checkout app was the first team to adopt GraphQL at PayPal, inspiring others to follow. Since then, GraphQL usage has grown significantly with 50 apps in production and a GraphQL public API powered by BrainTree. We provide support and training for teams adopting GraphQL.

Hello, everybody. Thank you for coming to my talk. Today, I'm going to be talking about adopting GraphQL in an enterprise. Before we get started in the talk, here's what we're going to talk about. We're going to talk about why GraphQL may be a good technology for an enterprise. Our story of adopting GraphQL in PayPal and the lessons we learned, the challenges we had, some best practices we adopted, and if you are interested in getting started with GraphQL, how you can get started.

Before I get started with my talk, I would introduce myself. My name is Shruti Kapoor. I'm a senior software engineer at PayPal. You can find me on Twitter at Shruti Kapoor08 or you can find me on Twitch at twitch.tv slash Shruti Kapoor where I share live streaming sessions of me working on something like a presentation like this. So I invite you to come and work on your side projects with me.

When we started adopting GraphQL at PayPal, when I first started PayPal I had actually never worked on GraphQL before. I kind of thought like GraphQL was like this technology that was used to fetch data, but I thought it was connected somehow to Facebook so I had no idea how to work with GraphQL. I thought it was related to GraphCMS and that was the extent of my knowledge. So when I got started at PayPal, my role in the team was to work on an internal project which was a brand new project and we were supposed to consume almost five internal APIs. These are all REST APIs. Our front-end application was supposed to be a NodeJS app, but what we used in the frontend of that NodeJS app was up to us and so we decided to use GraphQL as the frontend layer of that NodeJS app.

Why we decided to use GraphQL, I'll get into in a bit, but when I first got started into GraphQL at PayPal, there weren't a lot of people or a lot of teams that were using GraphQL. The main team that was using GraphQL was the Checkout app, which you may have seen when you check out at PayPal. That was actually the trailblazer of adoption of GraphQL at PayPal. They advocated GraphQL and the benefits of adopting GraphQL within PayPal and inspired the rest of the company to start adopting GraphQL. At the time, in 2018, we didn't have a lot of central support. Initially, teams were slowly starting to pick up GraphQL, but it was kind of very independent and dependent on the team itself to adopt GraphQL and kind of overcome challenges. Even the community was pretty early stages, but since then, a lot has changed outside in the community and at PayPal itself. Within PayPal, in the last three years, there's now 50 apps that use GraphQL in production. We do have a GraphQL public API as well that is powered by BrainTree. And in our internal Slack community, we have almost 500 members. So all of that is to say that GraphQL is picking up a lot in PayPal and we're heavily using GraphQL at PayPal. We have built internal tools to support GraphQL, especially the libraries that we had at PayPal. Now we provide infrastructure support and we provide training to adopt GraphQL for teams that are now adopting GraphQL, especially giving them some sample frontend apps and some sample backend apps to get them started easily on GraphQL.

2. Challenges of REST APIs and the Need for GraphQL

Short description:

GraphQL became the default pattern for frontend applications building a UI. We faced challenges with overfetching data from REST APIs, calling multiple APIs for one field, and maintaining consistency in integration. Upgrading APIs and dealing with inconsistent field names added complexity. We needed a technology that provided a uniform experience and easy integration. Detailed analytics and intelligent deprecation were also important. Versioning APIs posed challenges, and adding more data required considering breaking changes and client updates.

And for any frontend application that's building a UI, GraphQL has now become a default pattern for adopting, for putting it as the frontend layer of UI. Our reasons to adopt GraphQL at the time could be explained by understanding what our challenges at the time were. So when we were thinking of adopting a new technology or when we were thinking of a solution actually, these were some of the problems that we had at the time.

Our number one problem was that because, and this is specifically in regards to our company being a heavily REST, heavily REST API powered company, so we did have a lot of REST APIs and our frontend application that we were working on was supposed to talk to five different REST APIs. What ended up happening was that our UI may need like one field, but to get that one field, we would have to call a REST endpoint and the REST endpoint may be servicing a bunch of different UI applications as well. And so what ended up happening was we would call the REST API and we would get lots of overfetched data and that data would have to throw away on the client side and only use that one field. So one of the problems, one of the biggest problems we were facing at the time was we were fetching too much data from REST APIs and not using all of it.

And because we had so many different REST APIs, we also had to figure out which API to call to get the information we needed. And what that often involved was we first have to get authenticated from an API, then we'd have to use that token to call another API, maybe we get the user's ID from that information, from that API, and then we'd use that ID to maybe call their profile API and get their name and such and maybe their balance and such information. So basically what ended up happening was we'd call multiple round trips, use one field from one API and send it over to another API. And so that led to a lot of frustration because we were calling so many different APIs on our front-end applications.

Also because we were heavily versioned APIs, what ended up happening was that we would release a new version and if we had to update a field or if we had to rename a field, anybody who would be integrated with the previous version would now become outdated. And it was becoming really hard for us to deliver updates to these clients. It wasn't always feasible for clients to upgrade to our latest versions. So what ended up happening was most of our clients started staying on the older version while we were publishing newer versions of the API. Another problem was because we had REST APIs all across the board, what may have happened is that one field was called something else in one API like username, but something else in the other API like user or name. And so the integration experience itself was also very inconsistent. So as a frontend developer, we had to figure out what maybe do some formatting on the client end side, even to call the API itself and format our data before we send it to the server side. So the integration experience itself was quite inconsistent. So the right candidate that we were looking, would provide us the ability to have a uniform experience for all of the APIs that we were about to fetch across the board. And another important thing was the ease of integration across the board. So we wanted to make sure that the API, that the technology we would use, would not require a client, especially our sister companies, to have any prior information about our APIs itself. So for example, if our sister company like Braintree had to integrate with PayPal, we didn't want Braintree to know the ins and outs of calling a REST API, or calling an API on PayPal's side. We wanted them to have an easy interface that they could just integrate with, something that they'd be familiar with, without having to worry about what goes behind the scenes. Another thing that we wanted was because we were pushing out updates and we wanted to deprecate fields intelligently, we wanted to make sure that we have detailed analytics on which field was being used from the graph QL endpoints, or from our REST endpoints, or from our API endpoints. So we wanted to make sure that if we are pushing out updates, we are doing them intelligently and we have instrumentation behind those. Another thing that we noticed that was happening in our teams was our frontend and backend developers often would have this conversation. So the frontend developers would say like, we need to add more data. And one of the questions that was asked is, should we get version APIs? But the problem with version API is that if you do introduce breaking changes, then what is the best practice of introducing a breaking change? And if you go from V1 to V2, what happens to all of the clients that are not integrated with V2 yet? They do not get the updates yet. So what is the best solution there? Another alternative is if you need to ask more data.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

From GraphQL Zero to GraphQL Hero with RedwoodJS
GraphQL Galaxy 2021GraphQL Galaxy 2021
32 min
From GraphQL Zero to GraphQL Hero with RedwoodJS
Top Content
Tom Pressenwurter introduces Redwood.js, a full stack app framework for building GraphQL APIs easily and maintainably. He demonstrates a Redwood.js application with a React-based front end and a Node.js API. Redwood.js offers a simplified folder structure and schema for organizing the application. It provides easy data manipulation and CRUD operations through GraphQL functions. Redwood.js allows for easy implementation of new queries and directives, including authentication and limiting access to data. It is a stable and production-ready framework that integrates well with other front-end technologies.
Local State and Server Cache: Finding a Balance
Vue.js London Live 2021Vue.js London Live 2021
24 min
Local State and Server Cache: Finding a Balance
Top Content
This Talk discusses handling local state in software development, particularly when dealing with asynchronous behavior and API requests. It explores the challenges of managing global state and the need for actions when handling server data. The Talk also highlights the issue of fetching data not in Vuex and the challenges of keeping data up-to-date in Vuex. It mentions alternative tools like Apollo Client and React Query for handling local state. The Talk concludes with a discussion on GitLab going public and the celebration that followed.
Batteries Included Reimagined - The Revival of GraphQL Yoga
GraphQL Galaxy 2021GraphQL Galaxy 2021
33 min
Batteries Included Reimagined - The Revival of GraphQL Yoga
Envelope is a powerful GraphQL plugin system that simplifies server development and allows for powerful plugin integration. It provides conformity for large corporations with multiple GraphQL servers and can be used with various frameworks. Envelope acts as the Babel of GraphQL, allowing the use of non-spec features. The Guild offers GraphQL Hive, a service similar to Apollo Studio, and encourages collaboration with other frameworks and languages.
Rock Solid React and GraphQL Apps for People in a Hurry
GraphQL Galaxy 2022GraphQL Galaxy 2022
29 min
Rock Solid React and GraphQL Apps for People in a Hurry
The Talk discusses the challenges and advancements in using GraphQL and React together. It introduces RedwoodJS, a framework that simplifies frontend-backend integration and provides features like code generation, scaffolding, and authentication. The Talk demonstrates how to set up a Redwood project, generate layouts and models, and perform CRUD operations. Redwood automates many GraphQL parts and provides an easy way for developers to get started with GraphQL. It also highlights the benefits of Redwood and suggests checking out RedwoodJS.com for more information.
Step aside resolvers: a new approach to GraphQL execution
GraphQL Galaxy 2022GraphQL Galaxy 2022
16 min
Step aside resolvers: a new approach to GraphQL execution
GraphQL has made a huge impact in the way we build client applications, websites, and mobile apps. Despite the dominance of resolvers, the GraphQL specification does not mandate their use. Introducing Graphast, a new project that compiles GraphQL operations into execution and output plans, providing advanced optimizations. In GraphFast, instead of resolvers, we have plan resolvers that deal with future data. Graphfast plan resolvers are short and efficient, supporting all features of modern GraphQL.

Workshops on related topic

Build with SvelteKit and GraphQL
GraphQL Galaxy 2021GraphQL Galaxy 2021
140 min
Build with SvelteKit and GraphQL
Top Content
Featured WorkshopFree
Scott Spence
Scott Spence
Have you ever thought about building something that doesn't require a lot of boilerplate with a tiny bundle size? In this workshop, Scott Spence will go from hello world to covering routing and using endpoints in SvelteKit. You'll set up a backend GraphQL API then use GraphQL queries with SvelteKit to display the GraphQL API data. You'll build a fast secure project that uses SvelteKit's features, then deploy it as a fully static site. This course is for the Svelte curious who haven't had extensive experience with SvelteKit and want a deeper understanding of how to use it in practical applications.

Table of contents:
- Kick-off and Svelte introduction
- Initialise frontend project
- Tour of the SvelteKit skeleton project
- Configure backend project
- Query Data with GraphQL
- Fetching data to the frontend with GraphQL
- Styling
- Svelte directives
- Routing in SvelteKit
- Endpoints in SvelteKit
- Deploying to Netlify
- Navigation
- Mutations in GraphCMS
- Sending GraphQL Mutations via SvelteKit
- Q&A
Build Modern Applications Using GraphQL and Javascript
Node Congress 2024Node Congress 2024
152 min
Build Modern Applications Using GraphQL and Javascript
Featured Workshop
Emanuel Scirlet
Miguel Henriques
2 authors
Come and learn how you can supercharge your modern and secure applications using GraphQL and Javascript. In this workshop we will build a GraphQL API and we will demonstrate the benefits of the query language for APIs and what use cases that are fit for it. Basic Javascript knowledge required.
End-To-End Type Safety with React, GraphQL & Prisma
React Advanced Conference 2022React Advanced Conference 2022
95 min
End-To-End Type Safety with React, GraphQL & Prisma
Featured WorkshopFree
Sabin Adams
Sabin Adams
In this workshop, you will get a first-hand look at what end-to-end type safety is and why it is important. To accomplish this, you’ll be building a GraphQL API using modern, relevant tools which will be consumed by a React client.
Prerequisites: - Node.js installed on your machine (12.2.X / 14.X)- It is recommended (but not required) to use VS Code for the practical tasks- An IDE installed (VSCode recommended)- (Good to have)*A basic understanding of Node.js, React, and TypeScript
GraphQL for React Developers
GraphQL Galaxy 2022GraphQL Galaxy 2022
112 min
GraphQL for React Developers
Featured Workshop
Roy Derks
Roy Derks
There are many advantages to using GraphQL as a datasource for frontend development, compared to REST APIs. We developers in example need to write a lot of imperative code to retrieve data to display in our applications and handle state. With GraphQL you cannot only decrease the amount of code needed around data fetching and state-management you'll also get increased flexibility, better performance and most of all an improved developer experience. In this workshop you'll learn how GraphQL can improve your work as a frontend developer and how to handle GraphQL in your frontend React application.
Build a Headless WordPress App with Next.js and WPGraphQL
React Summit 2022React Summit 2022
173 min
Build a Headless WordPress App with Next.js and WPGraphQL
Top Content
WorkshopFree
Kellen Mace
Kellen Mace
In this workshop, you’ll learn how to build a Next.js app that uses Apollo Client to fetch data from a headless WordPress backend and use it to render the pages of your app. You’ll learn when you should consider a headless WordPress architecture, how to turn a WordPress backend into a GraphQL server, how to compose queries using the GraphiQL IDE, how to colocate GraphQL fragments with your components, and more.
Relational Database Modeling for GraphQL
GraphQL Galaxy 2020GraphQL Galaxy 2020
106 min
Relational Database Modeling for GraphQL
Top Content
WorkshopFree
Adron Hall
Adron Hall
In this workshop we'll dig deeper into data modeling. We'll start with a discussion about various database types and how they map to GraphQL. Once that groundwork is laid out, the focus will shift to specific types of databases and how to build data models that work best for GraphQL within various scenarios.
Table of contentsPart 1 - Hour 1      a. Relational Database Data Modeling      b. Comparing Relational and NoSQL Databases      c. GraphQL with the Database in mindPart 2 - Hour 2      a. Designing Relational Data Models      b. Relationship, Building MultijoinsTables      c. GraphQL & Relational Data Modeling Query Complexities
Prerequisites      a. Data modeling tool. The trainer will be using dbdiagram      b. Postgres, albeit no need to install this locally, as I'll be using a Postgres Dicker image, from Docker Hub for all examples      c. Hasura