GraphQL Query
A GraphQL query uses the { field(args) { subfield } } syntax to select exactly the data fields needed, avoiding over- and under-fetching.
Purpose
To let clients declare the fields and nested relations they need and have the server return exactly that data, eliminating REST over-fetching.
Mechanism
A query contains a field selection set; each field can take arguments, aliases, directives (@skip/@include), and nested sub-selections. Variables $var parameterize it. The server validates against the schema, executes resolvers, and returns the data.
Use cases
- Precise API data fetching
- Declarative frontend queries
- On-demand mobile fetching