GraphiQL
Explore and test GraphQL queries using GraphiQL, a web IDE with features like schema auto-fetch, query auto-complete, and documentation exploration.
For testing, you can run requests to the GraphQL endpoint with your preferred tools. We recommend:
The general form of a GraphQL query is as follows:
application/json
query
is a serialized JSON (properly escaped) and variables
is a JSON object. The variables
property can be skipped or could be set to null
if there are no GraphQL variables in the query.{
"query" : "...",
"variables" : {}
}
The following snippet shows a query example:
{
"query":"query GetCustomers($companyNo: Int, $pageSize: Int, $after :String)\n{\n useCompany(no: $companyNo)\n {\n associate(first: $pageSize, after: $after)\n {\n totalCount\n pageInfo\n {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n items\n {\n associateNo\n customerNo\n name\n }\n }\n }\n}",
"variables":{"companyNo":9112233,"pageSize":5},
"operationName":"GetCustomers"
}
In this example, you can also see the property operationName
that contains the name of the operation (that follows the query
or mutation
keyword).
The topic of GraphQL variables is addressed later in the tutorial in section Named queries and parameters.
Explore and test GraphQL queries using GraphiQL, a web IDE with features like schema auto-fetch, query auto-complete, and documentation exploration.
Postman supports GraphQL requests with built-in tools or raw POST requests, using application/json content type for queries and variables.
Insomnia offers superior GraphQL support with schema fetching, autocomplete, and an interactive schema explorer for efficient API management.
Learn how to make programmatic requests in C#/.NET 5 to execute GraphQL queries and deserialize JSON responses.