How LinkedIn Adopted A GraphQL Architecture for Product Development

LinkedIn Engineering Team
13 min readadvanced
--
View Original

Overview

The article discusses LinkedIn's transition to a GraphQL architecture for product development, highlighting the challenges faced with their existing microservices and the reasons for adopting GraphQL. It details the architectural choices made, including the use of an autogenerated type system and a distributed query execution endpoint.

What You'll Learn

1

How to implement GraphQL in a microservices architecture

2

Why to use autogenerated type systems in GraphQL

3

How to manage pre-registered queries for performance and security

Prerequisites & Requirements

  • Understanding of microservices architecture
  • Familiarity with GraphQL(optional)

Key Questions Answered

What challenges did LinkedIn face with their existing microservices?
LinkedIn faced several challenges with their microservices, including difficulties in identifying which microservice served the required data, resilience issues from multiple network calls, and inefficiencies due to duplicated downstream calls. These challenges prompted the need for a more streamlined solution.
How does LinkedIn's GraphQL architecture differ from standard implementations?
LinkedIn's GraphQL architecture is unique because it features an autogenerated type system, a distributed query execution endpoint located in each frontend microservice, and a restriction to only allow pre-registered queries for execution. This design enhances performance and security while integrating smoothly with existing microservices.
What is the purpose of the Query Registry Service in LinkedIn's GraphQL implementation?
The Query Registry Service allows client engineers to register their GraphQL queries, which are then cached for performance. This ensures that only pre-registered queries are executed in production, enhancing security and efficiency while providing a centralized management system for queries.

Technologies & Tools

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

API
Graphql
Used to streamline data fetching and improve the developer experience.
API
Rest.li
Serves as the foundational microservice architecture that integrates with GraphQL.
Backend
Graphql-java
Used for implementing the GraphQL query execution engine.

Key Actionable Insights

1
Implementing a GraphQL architecture can significantly streamline data fetching processes in microservices.
By adopting GraphQL, teams can reduce the number of network calls required to fetch data, thereby improving performance and developer productivity.
2
Utilizing autogenerated type systems can enhance the reliability of GraphQL APIs.
This approach minimizes manual schema management, allowing engineers to focus on building features rather than maintaining schemas.
3
Pre-registering queries can enhance security and performance in production environments.
By ensuring that only known queries are executed, teams can prevent malicious or inefficient queries from affecting system performance.

Common Pitfalls

1
Failing to manage the transition between Deco and GraphQL can lead to data format inconsistencies.
To avoid this, LinkedIn built a layer to convert responses to GraphQL format, ensuring smooth interoperability during the migration.

Related Concepts

Microservices Architecture
Graphql Best Practices
API Design Patterns