<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one
  ~ or more contributor license agreements.  See the NOTICE file
  ~ distributed with this work for additional information
  ~ regarding copyright ownership.  The ASF licenses this file
  ~ to you under the Apache License, Version 2.0 (the
  ~ "License"); you may not use this file except in compliance
  ~ with the License.  You may obtain a copy of the License at
  ~
  ~   http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing,
  ~ software distributed under the License is distributed on an
  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  ~ KIND, either express or implied.  See the License for the
  ~ specific language governing permissions and limitations
  ~ under the License.
-->

---
description: Manage queries on Postgres with Hasura
keywords:
  - hasura
  - docs
  - postgres
  - query
slug: index
---

# Postgres: GraphQL Queries

## Introduction

GraphQL queries are used to fetch data from the server.

Hasura GraphQL Engine auto-generates queries as part of the GraphQL schema from your Postgres schema model. It generates
a range of possible queries and operators that also work with relationships defined in your SQL schema.

All tables of the database tracked by the GraphQL Engine can be queried over the GraphQL endpoint. If you have a tracked
table in your database, its query field is added as a nested field under the `query_root` root level type.

:::info Postgres Compatibility

Hasura works with most [Postgres compatible flavours](/databases/postgres/index.mdx#postgres-compatible-flavors).

:::

## Auto-generated query field schema

**For example**, the auto-generated schema for the query field for a table `author` looks like the following:

```graphql
author (
  distinct_on: [author_select_column]
  where: author_bool_exp
  limit: Int
  offset: Int
  order_by:  [author_order_by!]
): [author]

# single object select
author_by_pk (
  # all primary key columns args
  id: Int!
): author
```

See the [Query API reference](/api-reference/graphql-api/query.mdx) for the full specifications.

:::info Note

If a table is not in the `public` Postgres schema, the query field will be of the format `<schema_name>_<table_name>`.

:::

## Exploring queries

You can explore the entire schema and the available queries using the `GraphiQL` interface in the Hasura Console.

Let’s take a look at the different queries you can run using the Hasura GraphQL Engine. We’ll use examples based on a
typical author/article schema for reference.

- [Simple object queries](/queries/postgres/simple-object-queries.mdx)
- [Nested object queries](/queries/postgres/nested-object-queries.mdx)
- [Aggregation queries](/queries/postgres/aggregation-queries.mdx)
- [Filter query results / search queries](/queries/postgres/filters/index.mdx)
- [Sort query results](/queries/postgres/sorting.mdx)
- [Distinct query results](/queries/postgres/distinct-queries.mdx)
- [Paginate query results](/queries/postgres/pagination.mdx)
- [Using multiple arguments](/queries/postgres/multiple-arguments.mdx)
- [Multiple queries in a request](/queries/postgres/multiple-queries.mdx)
- [Using variables / aliases / fragments / directives](/queries/postgres/variables-aliases-fragments-directives.mdx)
- [Query performance](/queries/postgres/performance.mdx)
