JSON body, with Content-Type: application/json
header:
{
"query": "{ helloPublic }"
}
In Postman GraphQL mode or in GraphiQL:
Query:
{ helloPublic }
Response:
{
"data": {
"helloPublic": "Hello public"
}
}
JSON body, with Content-Type: application/json
header:
{
"query": "query($num: Int!) { helloVariable(someNumber: $num) }",
"variables": {
"num": 3
}
}
In Postman GraphQL mode or in GraphiQL:
Query:
query($num: Int!) { helloVariable(num: $someNumber) }
Variables:
{
"num": 3
}
Reponse:
{
"data": {
"helloVariable": "Your number was 3"
}
}
In Postman GraphQL mode or in GraphiQL:
{ helloPrivate }
"errors": [
{
"message": "Not authenticated",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"helloPrivate"
],
"extensions": {
"code": "UNAUTHENTICATED",
"exception": {
"stacktrace": [
"AuthenticationError: Not authenticated",
In Postman GraphQL mode or in GraphiQL with the dummy user: whatever
header, which is used to simulate an authenticated user:
{
"data": {
"helloPrivate": "Hello private"
}
}
In Postman GraphQL mode or in GraphiQL:
query ($num: Int!) { helloBadInput(lessThanFive: $num) }
With variables:
{
"num": 3
}
Response:
{
"data": {
"helloBadInput": true
}
}
With variables:
{
"num": 10
}
Response:
{
"errors": [
{
"message": "Argument lessThanFive must be less than 5 (received 10)",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"helloBadInput"
],
"extensions": {
"code": "BAD_USER_INPUT",
"exception": {
"stacktrace": [
"UserInputError: Argument lessThanFive must be less than 5 (received 10)",