Set up your Clients

Configure Apollo Client for production with performance and security


This guide walks you through setting up Apollo Client for production use. You'll install the appropriate package for your framework, configure it to connect to your GraphQL endpoint, and add essential optimizations including caching, error handling, authentication, and persisted queries for improved performance and security.

Prerequisites

  • A client application (web or mobile) that you want to connect to GraphQL

  • Access to your router endpoint URL

By the end of the milestone, you'll have:

  • Apollo Client installed and configured

  • A query that fetches and displays data in the UI

Steps to complete

1. Set up Apollo Client

Follow the Getting Started with React guide to install and configure Apollo Client for your React application.

2. Retrieve and display data for your first query

Use the useQuery hook to fetch data from your GraphQL endpoint and render it in your React components.

3. Set up debugging tools

Set up Apollo Client DevTools to inspect queries, cache, and debug issues during development.

4. Repeat for each known production use case

For each of your known use cases, repeat step 2 to add all the queries, mutations, and subscriptions your application needs.

note
If your stack doesn't support Apollo Client, you can use any GraphQL-compliant client or integration that fits your platform. See View Integrations for alternatives.

Resources

Feedback

Edit in VSCode

Ask Community