Last updated
Tips for Using the GraphQL Playground
- Use the schema explorer (Docs panel) to browse available types and fields before writing queries
- Use variables instead of hardcoding values — makes queries reusable and easier to test with different inputs
- Save frequently used queries to the history for quick re-execution
- Use fragments to avoid repeating the same field selections across multiple queries
- Test error cases by passing invalid IDs or missing required fields
- Use introspection queries to understand an unfamiliar API's schema
- Open multiple tabs to test related operations side by side
Examples
Example 1: Connecting to a GraphQL Endpoint
Endpoint URL: https://api.example.com/graphql
HTTP Headers (for authenticated APIs):
{
"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"Content-Type": "application/json",
"X-API-Key": "your-api-key-here"
}
Example 2: Basic Query
query {
users {
id
name
email
}
}
Response:
{
"data": {
"users": [
{ "id": "1", "name": "Alice", "email": "alice@example.com" },
{ "id": "2", "name": "Bob", "email": "bob@example.com" }
]
}
}
Example 3: Query with Variables
Query (in the editor tab):
query GetUser($id: ID!) {
user(id: $id) {
id
name
email
role
createdAt
}
}
Variables (in the variables panel):
{
"id": "user_123"
}
Response:
{
"data": {
"user": {
"id": "user_123",
"name": "Alice",
"email": "alice@example.com",
"role": "ADMIN",
"createdAt": "2025-01-15T10:30:00Z"
}
}
}