2018-09-11 14:11:24 +03:00
|
|
|
|
Queries
|
|
|
|
|
=======
|
|
|
|
|
|
2018-12-03 15:12:24 +03:00
|
|
|
|
.. contents:: Table of contents
|
|
|
|
|
:backlinks: none
|
|
|
|
|
:depth: 1
|
|
|
|
|
:local:
|
|
|
|
|
|
2019-01-21 12:20:14 +03:00
|
|
|
|
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
|
2018-09-11 14:11:24 +03:00
|
|
|
|
schema.
|
|
|
|
|
|
2019-01-21 12:20:14 +03:00
|
|
|
|
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.
|
2018-12-03 15:12:24 +03:00
|
|
|
|
|
2019-02-06 09:39:36 +03:00
|
|
|
|
Auto-generated query field schema
|
|
|
|
|
---------------------------------
|
2018-12-03 15:12:24 +03:00
|
|
|
|
|
2019-02-06 09:39:36 +03:00
|
|
|
|
**For example**, the auto-generated schema for the query field for a table ``author`` looks like this:
|
2018-09-11 14:11:24 +03:00
|
|
|
|
|
|
|
|
|
.. code-block:: graphql
|
|
|
|
|
|
|
|
|
|
author (
|
2018-11-23 04:53:56 +03:00
|
|
|
|
distinct_on: [author_select_column]
|
2018-09-11 14:11:24 +03:00
|
|
|
|
where: author_bool_exp
|
|
|
|
|
limit: Int
|
|
|
|
|
offset: Int
|
|
|
|
|
order_by: [author_order_by!]
|
|
|
|
|
): [author]
|
|
|
|
|
|
2019-05-07 15:21:37 +03:00
|
|
|
|
See the :doc:`Query API reference <../api-reference/graphql-api/query>` for the full specifications
|
2018-09-11 14:11:24 +03:00
|
|
|
|
|
2018-12-03 15:12:24 +03:00
|
|
|
|
.. 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.
|
2018-09-11 14:11:24 +03:00
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
.. toctree::
|
|
|
|
|
:maxdepth: 1
|
|
|
|
|
|
|
|
|
|
simple-object-queries
|
|
|
|
|
nested-object-queries
|
2018-11-15 14:43:03 +03:00
|
|
|
|
aggregation-queries
|
2018-09-11 14:11:24 +03:00
|
|
|
|
query-filters
|
|
|
|
|
sorting
|
2019-01-25 06:31:54 +03:00
|
|
|
|
distinct-queries
|
2018-09-11 14:11:24 +03:00
|
|
|
|
pagination
|
|
|
|
|
Using multiple arguments <multiple-arguments>
|
|
|
|
|
multiple-queries
|
2019-01-25 06:31:54 +03:00
|
|
|
|
custom-functions
|
2018-11-15 14:43:03 +03:00
|
|
|
|
derived-data
|
2018-09-11 14:11:24 +03:00
|
|
|
|
control-access
|
2019-09-05 17:53:50 +03:00
|
|
|
|
variables-aliases-fragments-directives
|