๐ GraphQL Schema & Types Reference
| Type | Scalar Fields | Relational Resolvers |
|---|---|---|
| User | id, name, username, email, avatar, phone, website, address, company | posts: [Post], todos: [Todo] |
| Post | id, user_id, title, body, thumbnail | user: User, comments: [Comment] |
| Comment | id, post_id, name, email, body | post: Post |
| Todo | id, user_id, title, completed | user: User |
| AuthPayload | access_token, refresh_token, token_type, expires_in | user: User |
Execute GraphQL Queries & Mutations against Session Sandbox
| Name | Type | Required | Location | Description |
|---|---|---|---|---|
query |
String (Required) |
Optional | ||
variables |
Object (Optional) |
Optional | ||
operationName |
String (Optional) |
Optional |
curl -X POST 'http://playground-api-xi.vercel.app/graphql' \
-H 'Content-Type: application/json'
\
-b "pg_identity=your_cookie_uuid" \
-d '{
"query": "query GetUsersWithPosts($limit: Int) {\n users(limit: $limit) {\n id\n name\n email\n posts\n {\n id\n title\n }\n }\n}",
"variables": {
"limit": 3
}
}'
fetch('http://playground-api-xi.vercel.app/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json' },
credentials: 'include',
body: JSON.stringify({ "query": "query GetUsersWithPosts($limit: Int) {\n users(limit: $limit) {\n id\n name\n email\n posts\n {\n id\n title\n }\n }\n}", "variables": { "limit": 3 } })
})
.then(res => res.json())
.then(data => console.log(data));
import axios from 'axios';
axios.post('http://playground-api-xi.vercel.app/graphql', { "query": "query GetUsersWithPosts($limit: Int) {\n users(limit: $limit) {\n id\n name\n email\n posts\n {\n id\n title\n }\n }\n}", "variables": { "limit": 3 } }, {
withCredentials: true
}).then(response => console.log(response.data));
import requests
payload = { "query": "query GetUsersWithPosts($limit: Int) {\n users(limit: $limit) {\n id\n name\n email\n posts\n {\n id\n title\n }\n }\n}", "variables": { "limit": 3 } }
response =
requests.post('http://playground-api-xi.vercel.app/graphql', json=payload)
print(response.json())
package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
url :=
"http://playground-api-xi.vercel.app/graphql"
payload := []byte(`{ "query": "query GetUsersWithPosts($limit: Int) {\n users(limit: $limit) {\n id\n name\n email\n posts\n {\n id\n title\n }\n }\n}", "variables": { "limit": 3 } }`)
req, err := http.NewRequest("POST",
url, bytes.NewBuffer(payload))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type",
"application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil
{
panic(err)
}
defer resp.Body.Close()
body, _ :=
io.ReadAll(resp.Body)
fmt.Println(string(body))
}
import Foundation
let url = URL(string: "http://playground-api-xi.vercel.app/graphql")!
var request = URLRequest(url:
url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField:
"Content-Type")
let jsonString = """
{ "query": "query GetUsersWithPosts($limit: Int) {\n users(limit: $limit) {\n id\n name\n email\n posts\n {\n id\n title\n }\n }\n}", "variables": { "limit": 3 } }
"""
request.httpBody = jsonString.data(using:
.utf8)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data,
error == nil else { return }
let responseString = String(data: data, encoding: .utf8)
print(responseString ??
"")
}
task.resume()
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import
okhttp3.RequestBody.Companion.toRequestBody
val client = OkHttpClient()
val mediaType = "application/json;
charset=utf-8".toMediaType()
val body = """{ "query": "query GetUsersWithPosts($limit: Int) {\n users(limit: $limit) {\n id\n name\n email\n posts\n {\n id\n title\n }\n }\n}", "variables": { "limit": 3 } }""".toRequestBody(mediaType)
val request =
Request.Builder()
.url("http://playground-api-xi.vercel.app/graphql")
.post(body)
.addHeader("Content-Type",
"application/json")
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
use reqwest::Error;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Error> {
let client
= reqwest::Client::new();
let payload = json!({ "query": "query GetUsersWithPosts($limit: Int) {\n users(limit: $limit) {\n id\n name\n email\n posts\n {\n id\n title\n }\n }\n}", "variables": { "limit": 3 } });
let response = client
.post("http://playground-api-xi.vercel.app/graphql")
.header("Content-Type", "application/json")
.json(&payload)
.send()
.await?
.text()
.await?;
println!("{}", response);
Ok(())
}
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client();
$response = $client->request('POST', 'http://playground-api-xi.vercel.app/graphql', [
'headers' => [
'Content-Type' => 'application/json'
],
'json' => json_decode('{ "query": "query GetUsersWithPosts($limit: Int) {\n users(limit: $limit) {\n id\n name\n email\n posts\n {\n id\n title\n }\n }\n}", "variables": { "limit": 3 } }', true)
]);
echo $response->getBody();
Request Payload Example
{
"query": "query GetUsersWithPosts($limit: Int) {\n users(limit: $limit) {\n id\n name\n email\n posts\n {\n id\n title\n }\n }\n}",
"variables": {
"limit": 3
}
}
Response Schema Example
{
"data": {
"users": [
{
"id": "1",
"name": "Leanne Graham",
"email": "Sincere@april.biz",
"posts": [
{
"id": "1",
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit"
},
{
"id": "2",
"title": "qui est esse"
}
]
}
]
}
}
โก Try it out โ Test endpoint live Test now
Create Sandboxed Post via GraphQL Mutation
| Name | Type | Required | Location | Description |
|---|---|---|---|---|
query |
String (Required) |
Optional | ||
variables |
Object (Optional) |
Optional |
curl -X POST 'http://playground-api-xi.vercel.app/graphql' \
-H 'Content-Type: application/json'
\
-b "pg_identity=your_cookie_uuid" \
-d '{
"query": "mutation CreatePost($userId: ID!,\n $title: String!, $body: String) {\n createPost(user_id: $userId, title: $title, body: $body) {\n id\n user_id\n\n title\n body\n }\n}",
"variables": {
"userId": "1",
"title": "New GraphQL Post",
"body": "Created via GraphQL Gateway!"
}
}'
fetch('http://playground-api-xi.vercel.app/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json' },
credentials: 'include',
body: JSON.stringify({ "query": "mutation CreatePost($userId: ID!,\n $title: String!, $body: String) {\n createPost(user_id: $userId, title: $title, body: $body) {\n id\n user_id\n\n title\n body\n }\n}", "variables": { "userId": "1", "title": "New GraphQL Post", "body": "Created via GraphQL Gateway!" } })
})
.then(res => res.json())
.then(data => console.log(data));
import axios from 'axios';
axios.post('http://playground-api-xi.vercel.app/graphql', { "query": "mutation CreatePost($userId: ID!,\n $title: String!, $body: String) {\n createPost(user_id: $userId, title: $title, body: $body) {\n id\n user_id\n\n title\n body\n }\n}", "variables": { "userId": "1", "title": "New GraphQL Post", "body": "Created via GraphQL Gateway!" } }, {
withCredentials: true
}).then(response => console.log(response.data));
import requests
payload = { "query": "mutation CreatePost($userId: ID!,\n $title: String!, $body: String) {\n createPost(user_id: $userId, title: $title, body: $body) {\n id\n user_id\n\n title\n body\n }\n}", "variables": { "userId": "1", "title": "New GraphQL Post", "body": "Created via GraphQL Gateway!" } }
response =
requests.post('http://playground-api-xi.vercel.app/graphql', json=payload)
print(response.json())
package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
url :=
"http://playground-api-xi.vercel.app/graphql"
payload := []byte(`{ "query": "mutation CreatePost($userId: ID!,\n $title: String!, $body: String) {\n createPost(user_id: $userId, title: $title, body: $body) {\n id\n user_id\n\n title\n body\n }\n}", "variables": { "userId": "1", "title": "New GraphQL Post", "body": "Created via GraphQL Gateway!" } }`)
req, err := http.NewRequest("POST",
url, bytes.NewBuffer(payload))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type",
"application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil
{
panic(err)
}
defer resp.Body.Close()
body, _ :=
io.ReadAll(resp.Body)
fmt.Println(string(body))
}
import Foundation
let url = URL(string: "http://playground-api-xi.vercel.app/graphql")!
var request = URLRequest(url:
url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField:
"Content-Type")
let jsonString = """
{ "query": "mutation CreatePost($userId: ID!,\n $title: String!, $body: String) {\n createPost(user_id: $userId, title: $title, body: $body) {\n id\n user_id\n\n title\n body\n }\n}", "variables": { "userId": "1", "title": "New GraphQL Post", "body": "Created via GraphQL Gateway!" } }
"""
request.httpBody = jsonString.data(using:
.utf8)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data,
error == nil else { return }
let responseString = String(data: data, encoding: .utf8)
print(responseString ??
"")
}
task.resume()
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import
okhttp3.RequestBody.Companion.toRequestBody
val client = OkHttpClient()
val mediaType = "application/json;
charset=utf-8".toMediaType()
val body = """{ "query": "mutation CreatePost($userId: ID!,\n $title: String!, $body: String) {\n createPost(user_id: $userId, title: $title, body: $body) {\n id\n user_id\n\n title\n body\n }\n}", "variables": { "userId": "1", "title": "New GraphQL Post", "body": "Created via GraphQL Gateway!" } }""".toRequestBody(mediaType)
val request =
Request.Builder()
.url("http://playground-api-xi.vercel.app/graphql")
.post(body)
.addHeader("Content-Type",
"application/json")
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
use reqwest::Error;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Error> {
let client
= reqwest::Client::new();
let payload = json!({ "query": "mutation CreatePost($userId: ID!,\n $title: String!, $body: String) {\n createPost(user_id: $userId, title: $title, body: $body) {\n id\n user_id\n\n title\n body\n }\n}", "variables": { "userId": "1", "title": "New GraphQL Post", "body": "Created via GraphQL Gateway!" } });
let response = client
.post("http://playground-api-xi.vercel.app/graphql")
.header("Content-Type", "application/json")
.json(&payload)
.send()
.await?
.text()
.await?;
println!("{}", response);
Ok(())
}
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client();
$response = $client->request('POST', 'http://playground-api-xi.vercel.app/graphql', [
'headers' => [
'Content-Type' => 'application/json'
],
'json' => json_decode('{ "query": "mutation CreatePost($userId: ID!,\n $title: String!, $body: String) {\n createPost(user_id: $userId, title: $title, body: $body) {\n id\n user_id\n\n title\n body\n }\n}", "variables": { "userId": "1", "title": "New GraphQL Post", "body": "Created via GraphQL Gateway!" } }', true)
]);
echo $response->getBody();
Request Payload Example
{
"query": "mutation CreatePost($userId: ID!,\n $title: String!, $body: String) {\n createPost(user_id: $userId, title: $title, body: $body) {\n id\n user_id\n\n title\n body\n }\n}",
"variables": {
"userId": "1",
"title": "New GraphQL Post",
"body": "Created via GraphQL Gateway!"
}
}
Response Schema Example
{
"data": {
"createPost": {
"id": "local-a1b2c3d4-5678-90ef",
"user_id": "1",
"title": "New GraphQL Post",
"body": "Created via GraphQL Gateway!"
}
}
}
โก Try it out โ Test endpoint live Test now
Authenticate via GraphQL login mutation & query authenticated profile (me)
| Name | Type | Required | Location | Description |
|---|---|---|---|---|
query |
String (Required) |
Optional | ||
variables |
Object (Optional) |
Optional |
curl -X POST 'http://playground-api-xi.vercel.app/graphql' \
-H 'Content-Type: application/json'
\
-b "pg_identity=your_cookie_uuid" \
-d '{
"query": "mutation Login($username: String!) {\n login(username: $username) {\n access_token\n refresh_token\n token_type\n user {\n id\n name\n email\n }\n }\n}",
"variables": {
"username": "Bret"
}
}'
fetch('http://playground-api-xi.vercel.app/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json' },
credentials: 'include',
body: JSON.stringify({ "query": "mutation Login($username: String!) {\n login(username: $username) {\n access_token\n refresh_token\n token_type\n user {\n id\n name\n email\n }\n }\n}", "variables": { "username": "Bret" } })
})
.then(res => res.json())
.then(data => console.log(data));
import axios from 'axios';
axios.post('http://playground-api-xi.vercel.app/graphql', { "query": "mutation Login($username: String!) {\n login(username: $username) {\n access_token\n refresh_token\n token_type\n user {\n id\n name\n email\n }\n }\n}", "variables": { "username": "Bret" } }, {
withCredentials: true
}).then(response => console.log(response.data));
import requests
payload = { "query": "mutation Login($username: String!) {\n login(username: $username) {\n access_token\n refresh_token\n token_type\n user {\n id\n name\n email\n }\n }\n}", "variables": { "username": "Bret" } }
response =
requests.post('http://playground-api-xi.vercel.app/graphql', json=payload)
print(response.json())
package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
url :=
"http://playground-api-xi.vercel.app/graphql"
payload := []byte(`{ "query": "mutation Login($username: String!) {\n login(username: $username) {\n access_token\n refresh_token\n token_type\n user {\n id\n name\n email\n }\n }\n}", "variables": { "username": "Bret" } }`)
req, err := http.NewRequest("POST",
url, bytes.NewBuffer(payload))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type",
"application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil
{
panic(err)
}
defer resp.Body.Close()
body, _ :=
io.ReadAll(resp.Body)
fmt.Println(string(body))
}
import Foundation
let url = URL(string: "http://playground-api-xi.vercel.app/graphql")!
var request = URLRequest(url:
url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField:
"Content-Type")
let jsonString = """
{ "query": "mutation Login($username: String!) {\n login(username: $username) {\n access_token\n refresh_token\n token_type\n user {\n id\n name\n email\n }\n }\n}", "variables": { "username": "Bret" } }
"""
request.httpBody = jsonString.data(using:
.utf8)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data,
error == nil else { return }
let responseString = String(data: data, encoding: .utf8)
print(responseString ??
"")
}
task.resume()
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import
okhttp3.RequestBody.Companion.toRequestBody
val client = OkHttpClient()
val mediaType = "application/json;
charset=utf-8".toMediaType()
val body = """{ "query": "mutation Login($username: String!) {\n login(username: $username) {\n access_token\n refresh_token\n token_type\n user {\n id\n name\n email\n }\n }\n}", "variables": { "username": "Bret" } }""".toRequestBody(mediaType)
val request =
Request.Builder()
.url("http://playground-api-xi.vercel.app/graphql")
.post(body)
.addHeader("Content-Type",
"application/json")
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
use reqwest::Error;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Error> {
let client
= reqwest::Client::new();
let payload = json!({ "query": "mutation Login($username: String!) {\n login(username: $username) {\n access_token\n refresh_token\n token_type\n user {\n id\n name\n email\n }\n }\n}", "variables": { "username": "Bret" } });
let response = client
.post("http://playground-api-xi.vercel.app/graphql")
.header("Content-Type", "application/json")
.json(&payload)
.send()
.await?
.text()
.await?;
println!("{}", response);
Ok(())
}
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client();
$response = $client->request('POST', 'http://playground-api-xi.vercel.app/graphql', [
'headers' => [
'Content-Type' => 'application/json'
],
'json' => json_decode('{ "query": "mutation Login($username: String!) {\n login(username: $username) {\n access_token\n refresh_token\n token_type\n user {\n id\n name\n email\n }\n }\n}", "variables": { "username": "Bret" } }', true)
]);
echo $response->getBody();
Request Payload Example
{
"query": "mutation Login($username: String!) {\n login(username: $username) {\n access_token\n refresh_token\n token_type\n user {\n id\n name\n email\n }\n }\n}",
"variables": {
"username": "Bret"
}
}
Response Schema Example
{
"data": {
"login": {
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6...",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6...",
"token_type": "Bearer",
"user": {
"id": "1",
"name": "Leanne Graham",
"email": "sincere@april.biz"
}
}
}
}