Basics of Queries
Introduction
GraphQL queries are used to read data by interacting with models in your Hasura DDN project.
Queries can be used to return multiple records while specifying exactly which fields to include in the response. You can also query for unique records with the same level of control, retrieving a single result that matches your desired fields.
Further, you can filter queries to only return records that match your specific conditions where certain fields meet explicit criteria.
In addition to fetching records, queries can perform aggregations, which allow you to compute and summarize data. For example, you can count the number of records, calculate averages, or find totals directly in the query response.
Since the GraphQL API is self-documenting, you can write queries manually or use tools like auto-completion and the GraphiQL explorer in the Hasura DDN console to help you build and test them. GraphiQL displays the available root-level types, fields, and relationships, making it easier to construct queries accurately.
Configuration
You can configure the overall usage of queries in your GraphQL API using
the GraphQlConfig
object in your metadata.
Additionally, you can customize individual queries by modifying
the GraphQlDefinition
metadata object for a model.
Next steps
Depending on the features enabled by a data connector, you will have access to a range of queries as defined here.
- Simple Queries
- Nested Queries
- Sort Query Results
- Paginate Query Results
- Multiple Arguments
- Multiple Queries
- Variables, Aliases, Fragments, Directives
- Filtering Queries
For questions about feature support, check out the connector reference docs.