A GraphQL query is a read operation. Queries let you specify exactly which fields you want to retrieve. Fields can be nested to fetch related data in a single request.
GraphQL
Beginner
10 min read
GraphQL Queries
Example
# Basic query
query {
books {
title
author
year
}
}
# Query with arguments
query {
book(id: "42") {
title
author {
name
bio
}
reviews {
rating
comment
}
}
}
# Named query with variables
query GetBook($bookId: ID!, $reviewLimit: Int = 10) {
book(id: $bookId) {
title
reviews(limit: $reviewLimit) {
rating
comment
author { name }
}
}
}
# Variables (sent as JSON)
{
"bookId": "42",
"reviewLimit": 5
}
Related Resources
GraphQL Reference
Complete tag & property list
GraphQL How-To Guides
Step-by-step practical guides
GraphQL Exercises
Practice what you've learned
More in GraphQL