Join us for GraphQL Summit, October 10-12 in San Diego. Use promo code ODYSSEY for $400 off your pass.
Launch GraphOS Studio

Why adopt GraphQL?

GraphQL and Apollo help you ship features faster

Managing data in modern applications is challenging. Most applications require:

  • Distinct front-end clients for multiple platforms (web, iOS, etc.), each with different data requirements
  • A backend that serves data to clients from multiple sources (Postgres, Redis, etc.)
  • Complex state and cache management for both the frontend and the backend

By adopting GraphQL and Apollo, you can reduce these challenges considerably. GraphQL's declarative model helps you create a consistent, predictable API you can use across all of your clients. As you add, remove, and migrate backend data stores, that API doesn't change from the client's perspective.

Even with many other advantages, GraphQL's single greatest benefit is the developer experience it provides. It's straightforward to add new types and s to your API, and similarly straightforward for your clients to begin using those fields. This helps you design, develop, and deploy features quickly.

Combined with Apollo open-source libraries, complex considerations like caching, data normalization, and optimistic UI rendering become straightforward as well.

GraphQL provides declarative, efficient data fetching

GraphQL's declarative approach to data fetching provides significant performance and quality-of-life improvements over a REST API.

Consider a webpage that displays a list of adorable pets that are available for adoption at local animal shelters. 🐶

Using REST, the page might need to:

  1. GET a list of shelters and their corresponding pet_ids from the /api/shelters endpoint
  2. GET each individual pet's details (name, photo URL, etc.) with a separate request to /api/pets/PET_ID

This solution requires multiple dependent network requests, which can result in slower page loads and additional battery consumption on mobile devices. This logic is also difficult to reuse on other pages that display slightly different data.

Using GraphQL, the page can obtain all of this data with a single query to a single endpoint. That query looks like this:

query GetPetsByShelter {
shelters {
pets {

This query describes the shape of the data we want to receive from the GraphQL server. The server takes care of combining and filtering back-end data to return exactly what we ask for. This keeps payload sizes small, especially compared to a REST endpoint that might return hundreds of unnecessary s.

To execute a query like the one above, the page uses a GraphQL client such as Apollo Client, with code that resembles the following (in the case of a React app):

// Define the query
const GET_PETS_BY_SHELTER = gql`
query GetPetsByShelter {
shelters {
pets {
function MainPage() {
// Execute the query within the component that uses its result
const { loading, error, data } = useQuery(GET_PETS_BY_SHELTER);
if (error) return <Error />;
if (loading || !data) return <Fetching />;
// Populate the component using the query's result
return <PetList shelters={data.shelters} />;

Apollo Client's useQuery hook takes care of the request lifecycle from start to finish, including tracking loading and error states for you. There’s no middleware to set up or boilerplate to write before making your first request. All you need to do is describe the data your component needs and let Apollo Client do the heavy lifting. 💪

GraphQL enables powerful tooling

Thanks to GraphQL's strong typing and built-in support for introspection, developer tools for GraphQL are extremely powerful. These tools let you do things like:

  • Explore the full structure of a , complete with docstrings
  • Compose new s with live validation and autocomplete
  • Register your with a management service that tracks and checks changes

What is Apollo GraphOS?

Apollo provides a cloud-hosted collection of tools that help you build your graph, measure its performance, and grow it safely. These tools are together known as Apollo GraphOS.

After registering your with , you can use the Apollo Studio Explorer to inspect all of its types and s. You can also build and run queries against your running server:

Studio Explorer tab

Apollo Client DevTools

The Apollo Client DevTools extension for Chrome and Firefox enables you to inspect your Apollo Client cache, track active queries, and view s. It also includes an embedded version of the , which helps you test queries while you're working on front-end code.

Apollo DevTools

GraphQL is production-ready

GraphQL's adoption has risen steadily since Facebook published the original specification in 2015. For more and more organizations, the benefits of GraphQL have taken it from a curious engineer's hack-week experiment to the heart of the enterprise data layer.

GraphQL scales with the requirements of even the largest organizations, largely because of its powerful tooling and its compatibility with a federated architecture.

In a federated architecture (also known as a supergraph), a single GraphQL is split across multiple back-end services. Each team in an organization can then own exactly the services (and the corresponding parts of the schema) that they should.

Organizations using GraphQL

Here are a few blog posts from organizations that have benefited from adopting GraphQL in their production environment:

GraphQL trade-offs

When deciding whether to adopt a technology, it's just as important to understand the technology's limitations as it is to understand its benefits.

Consider the following trade-offs when using GraphQL:

Change management

GraphQL introduces a new conceptual model for representing and interacting with data. An organization that's comfortable with this model can design, implement, and ship features quickly. However, the process of becoming comfortable with this model takes time.

  • Front-end developers must come up to speed with a new API for fetching and manipulating data.
  • Back-end developers must come up to speed with how to handle incoming requests from the frontend.
  • Developers across the organization must collaborate on a single, product-driven GraphQL and appoint individuals as the official maintainers of that schema.

The Apollo docs, blog, and community forum are all here to help your organization adopt GraphQL and take full advantage of it.

Potential for slow operations

Your GraphQL schema defines which types and s your clients can query. Your GraphQL server's resolvers define how those types and s are populated from your data stores.

Depending on your and your definitions, your server might inadvertently support GraphQL s that execute very slowly, or even max out your server's resources.

Consequently, it's important to design your such that it supports the s your clients need, without supporting unnecessary s that affect performance. It's also helpful to set up trace reporting for your GraphQL server, enabling you to identify and improve slow s.

Learn about query-driven schema design

Incompatibility with web browser caching

Although Apollo Client provides powerful client-side caching features, those features often require some configuration to get the most out of them. The automatic caching provided by your web browser does not interact well with GraphQL.

Web browsers cache fetched data according to its URL. With GraphQL, you fetch all data from the same URL (the URL of your GraphQL server). Consequently, you can't rely on the cached value for this URL.

What is GraphOS?
Edit on GitHubEditForumsDiscord