Enter a GraphQL query to convert it to a JSON body for a POST request.
If you're connecting to a GraphQL server using HTTPS requests, the server probably expects you to send a POST request with the query in the JSON body like this:
{ "query": "query { countries { code name capital continent { name } }}" }So you need your GraphQL query to be in this format to send it to the server.
Unfortunately, most GraphQL API docs/ playgrounds just give you straight GraphQL queries like this:
query { countries { code name capital continent { name } } }You cannot use this directly in the request body as it is not valid JSON.
{ "query": "query { countries { code name capital { name } } }", "operationName": "MY OPERATION NAME", "variables": { "code": "Gb" } }
Having trouble? Try clicking the "Beautify" button to validate and format your query. You will be shown any errors.