GraphQL server accepts both GET and POST requests.
GraphQL Server accepts POST requests with a JSON body. A valid request must contain either a
query or an
operationName (or both, in case of a named query), and may include
variables. Here’s an example for a valid body of a post request:
Variables can be an object or a JSON-encoded string. I.e. the following is equivalent to the previous query:
A batch of queries can be sent by simply sending a JSON-encoded array of queries, e.g.
If a batch of queries is sent, the response will be an array of GraphQL responses.
If GraphQL Server is running under a different origin than your client, you will need to enable CORS support on the server, or proxy the GraphQL requests through a web server under the main origin.
GraphQL server also accepts GET requests. A GET request must pass query and optionally variables and operationName in the URL.
Here is the same query from above in a well-formatted GET request to GraphQL Server:
caveat: Mutations cannot be executed via GET requests.