⬡ GraphQL Beginner

What is a GraphQL query?

Answer

A query is a read operation in GraphQL — the equivalent of an HTTP GET in REST. It retrieves data from the server without modifying anything. Queries specify exactly which fields to fetch. Example: query { user(id: "1") { name email posts { title } } } — this fetches the name, email, and post titles for user 1 in a single request. The response mirrors the query structure. Queries can be named (best practice): query GetUser($id: ID!) { user(id: $id) { name } }. Variables make queries reusable. Aliases let you rename fields: { admin: user(id: "1") { name } }. Queries can be deeply nested to fetch entire object graphs.