Here's your chance to speak at GraphQL Summit in New York City, October 8 - 10, 2024! 🏙️ Submit your proposal by May 31.
Launch GraphOS Studio

Operation request format

How to send requests to the Apollo Router over HTTP

By default, almost every IDE and client library takes care of sending in a format that the supports. This article describes that format, which is also described on and in this preliminary spec.

The Apollo Router accepts queries, , and sent as POST requests. It also accepts queries sent as GET requests.

POST requests

The Apollo Router accepts POST requests with a JSON body. A valid request contains a query , along with optional variables and an operationName (if query contains multiple possible operations).

Let's say we want to execute the following :

query GetBestSellers($category: ProductCategory) {
bestSellers(category: $category) {

Here's an example of a valid POST request body for that query:

"query":"query GetBestSellers($category: ProductCategory){bestSellers(category: $category){title}}",
"operationName": "GetBestSellers",
"variables": { "category": "BOOKS" }

Note that operationName isn't required for this particular request body, because query includes only one definition.

You can execute this query against an Apollo-hosted example server right now with the following curl command:

curl --request POST \
-H 'Content-Type: application/json' \
--data '{"query":"query GetBestSellers($category:ProductCategory){bestSellers(category: $category){title}}", "operationName":"GetBestSellers", "variables":{"category":"BOOKS"}}' \

The Apollo Router's default landing page provides a curl command you can use to execute a test query on your own server:

GET requests

The Apollo Router also accepts GET requests for queries (but not mutations). With a GET request, query details (query, operationName, variables) are provided as URL query parameters. The variables option is a URL-escaped JSON object.

Here's the same query from POST requests formatted for a curl GET request:

curl --request GET \

Persisted queries protocol

The () and () features of the Apollo Router use a separate protocol to send the operation information in the extensions. This protocal can also use HTTP POST or GET. See the docs on the APQ protocol for details.

@defer support
Query batching
Edit on GitHubEditForumsDiscord

© 2024 Apollo Graph Inc.

Privacy Policy