1. Home
  2. Docs
  3. Advanced Guides
  4. Query batching with WPGraphQL

Query batching with WPGraphQL

WPGraphQL allows clients to interact with WordPress via HTTP requests the /graphql API endpoint, or within the PHP context via execution of the do_graphql_request() function. 

Many GraphQL Queries or Mutations can be executed in one API request or one page-load. 

For example, if I were to use GraphQL to hydrate data for a shortcode I could have many shortcodes on my page and GraphQL would execute multiple times on that page. 

Making many requests via the /graphql API endpoint is similar. An array of requests can be sent to the endpoint and an array of responses will be returned. 

Screenshot showing multiple GraphQL queries in a single HTTP request, in the Postman API client

Smart GraphQL clients, such as Apollo Client, can take advantage of this feature to process multiple GraphQL requests in a single API call, making interactions with the server more efficient by reducing the number of round-trips needed. 

If you use Apollo Client, you can read about configuring the batch HTTP link here.

You can read more about Query Batching here.

Was this article helpful to you? Yes No

How can we help?