GraphQL
Queries
Read data with selection sets.
By EZ4Code Team
queryread
Code
query GetBooks($limit: Int = 10) {
books(limit: $limit) {
id
title
author {
name
}
}
}
query GetBook($id: ID!) {
book(id: $id) {
title
pages
}
}Explanation
A query operation reads data by selecting fields from the root Query type, nesting as deeply as the schema allows. Variables declared in the header are passed alongside the document in a separate JSON payload. The client receives exactly the fields it asks for, no more and no less, which prevents over-fetching.