Reconciling GraphQL and Thrift at Airbnb

Our frontend engineers wanted rapid iteration and flexibility from GraphQL, while our backend engineers wanted stability and specificity…

Adam Neary
10 min readadvanced
--
View Original

Overview

The article discusses how Airbnb reconciled the differing needs of frontend and backend engineers by integrating GraphQL as an API layer on top of their existing Thrift-based services. It details the architectural decisions made to ensure flexibility for frontend developers while maintaining stability and specificity for backend services.

What You'll Learn

1

How to integrate GraphQL with existing Thrift services

2

Why using GraphQL as an API layer can enhance frontend flexibility

3

When to use Thrift/GraphQL translators for schema generation

Prerequisites & Requirements

  • Understanding of GraphQL and Thrift concepts
  • Familiarity with Apollo for GraphQL implementation(optional)

Key Questions Answered

How does Airbnb integrate GraphQL with Thrift?
Airbnb integrates GraphQL with Thrift by embedding Translators within each Presentation Service, which compile Thrift structs and service functions into GraphQL schema definitions. This allows for a seamless connection between the two technologies, enabling frontend engineers to query data without compromising backend stability.
What are the benefits of using GraphQL as an API layer?
Using GraphQL as an API layer provides a strongly typed API schema, flexibility in field selection, and supports cross-platform client-side development. This allows frontend engineers to iterate rapidly without needing constant backend involvement, thus enhancing productivity and responsiveness to user needs.
What challenges did Airbnb face when adopting GraphQL?
Airbnb faced challenges such as concerns over performance regressions and the potential for client engineers to create inefficient queries that could impact backend services. These concerns were addressed by framing GraphQL as a complementary API layer rather than a competing strategy.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Key Actionable Insights

1
Implementing GraphQL as an API layer can significantly improve frontend development speed and flexibility.
By allowing frontend engineers to define their data needs without backend intervention, teams can respond more quickly to changing requirements and user feedback.
2
Using Translators to compile Thrift to GraphQL schemas automates and simplifies the integration process.
This approach minimizes manual coding and potential errors, allowing service engineers to focus on building features rather than managing schema definitions.
3
Consolidating multiple Presentation Services into a single Gateway Service can streamline query management.
This reduces the complexity of client interactions with the backend and allows for better routing and schema stitching, enhancing overall system performance.

Common Pitfalls

1
Allowing client engineers to create arbitrary queries can lead to performance issues and regressions.
This happens when there are no strict controls over query definitions, which can result in inefficient data fetching and increased latency.