Apollo Client (Web)
IntroductionWhy Apollo Client?Get started
Core concepts
Caching
Pagination
Local State
Development & Testing
Performance
Integrations
Networking
API Reference
ChangelogMigrating to Apollo Client 4.0Versioning Policy

createQueryPreloader

Apollo Client API reference


A higher order function that returns a preloadQuery function which can be used to begin loading a query with the given client. This is useful when you want to start loading a query as early as possible outside of a React component.

Refer to the Suspense - Initiating queries outside React section for a more in-depth overview.

Example

JavaScript
1 const preloadQuery = createQueryPreloader(client);

Signature

TypeScript
1createQueryPreloader(
2  client: ApolloClient
3): PreloadQueryFunction
(src/react/query-preloader/createQueryPreloader.ts)

Parameters

Name / Type
Description
client
ApolloClient

The ApolloClient instance that will be used to load queries from the returned preloadQuery function.

Result

The `preloadQuery` function.
PreloadQueryFunction