2020-01-14 15:57:45 +03:00
.. meta ::
:description: Hasura GraphQL API queries and subscriptions API reference
:keywords: hasura, docs, GraphQL API, API reference, query, subscription
2020-03-11 22:42:36 +03:00
.. _graphql_api_query:
2019-02-06 09:39:36 +03:00
API Reference - Query / Subscription
====================================
2018-09-11 14:11:24 +03:00
2018-12-03 15:12:24 +03:00
.. contents :: Table of contents
:backlinks: none
:depth: 3
:local:
2020-05-18 14:13:57 +03:00
**query** / **subscription** syntax
-----------------------------------
2018-09-11 14:11:24 +03:00
.. code-block :: none
query|subscription [<op-name> ] {
object [([argument])]{
object-fields
}
}
.. list-table ::
:header-rows: 1
* - Key
- Required
- Schema
- Description
* - op-name
- false
- Value
- Name query/subscription for observability
* - object
- true
- Object_
- Name of the table/object
* - argument
- false
- Argument_
2018-10-04 07:09:47 +03:00
- One or more of filter criteria, instructions for sort order or pagination
2018-09-11 14:11:24 +03:00
2020-06-19 16:20:56 +03:00
**Example: Query**
2018-09-11 14:11:24 +03:00
.. code-block :: graphql
query {
2018-10-26 14:57:33 +03:00
author(where: {articles: {rating: {_gte: 4}}} order_by: {name: asc}) {
2018-09-11 14:11:24 +03:00
id
name
}
}
2020-06-19 16:20:56 +03:00
**Example: Subscription**
2018-09-11 14:11:24 +03:00
.. code-block :: graphql
subscription {
2018-10-26 14:57:33 +03:00
author(where: {articles: rating: {_gte: 4}}} order_by: {name: asc}) {
2018-09-11 14:11:24 +03:00
id
name
}
}
.. note ::
2018-10-26 14:57:33 +03:00
2020-03-11 22:42:36 +03:00
For more examples and details of usage, please see :ref: `this <queries>` .
2018-09-11 14:11:24 +03:00
2020-05-18 14:13:57 +03:00
**query_by_pk** / **subscription_by_pk** syntax
-----------------------------------------------
.. code-block :: none
query|subscription [<op-name> ] {
<query-field-name> (
column1: value1
column2: value2
)
<object-fields>
}
.. list-table ::
:header-rows: 1
* - Key
- Required
- Schema
- Description
* - op-name
- false
- Value
- Name query/subscription for observability
* - query-field-name
- true
- Value
- Name of the auto-generated query field, e.g. *article_by_pk*
2020-06-19 16:20:56 +03:00
**Example: Query by PK**
2020-05-18 14:13:57 +03:00
.. code-block :: graphql
query {
article_by_pk(id: 1) {
id
title
}
}
2020-06-19 16:20:56 +03:00
**Example: Subscription by PK**
2020-05-18 14:13:57 +03:00
.. code-block :: graphql
subscription {
article_by_pk(id: 1) {
id
title
}
}
2018-09-11 14:11:24 +03:00
Syntax definitions
------------------
Object
^^^^^^
2019-02-06 09:39:36 +03:00
.. parsed-literal ::
SimpleObject_ | AggregateObject_
.. _SimpleObject:
2018-12-17 14:58:29 +03:00
2019-09-11 10:17:14 +03:00
Simple object
2018-12-03 15:12:24 +03:00
***** ***** ***
2018-11-15 14:43:03 +03:00
2018-09-11 14:11:24 +03:00
.. code-block :: none
object-name {
field1
field2
2019-03-25 16:45:35 +03:00
json_field[(path: String)]
2018-09-11 14:11:24 +03:00
..
nested object1
nested object2
2018-11-15 14:43:03 +03:00
aggregate nested object1
2018-09-11 14:11:24 +03:00
..
}
2019-03-25 16:45:35 +03:00
.. list-table ::
:header-rows: 1
* - Key
- Required
- Schema
- Description
* - path
- false
- Value
2020-07-09 11:42:33 +03:00
- `` path `` argument of `` json `` /`` jsonb `` follows simple `JSONPath specification <https://github.com/json-path/JsonPath> `__ . However, prefix symbol `` $. `` is optional.
2019-03-25 16:45:35 +03:00
2020-06-19 16:20:56 +03:00
*Example*
2018-09-11 14:11:24 +03:00
.. code-block :: graphql
author {
2019-03-25 16:45:35 +03:00
id # scalar integer field
2019-07-15 11:52:45 +03:00
2019-03-25 16:45:35 +03:00
name # scalar text field
address(path: "$.city") # scalar JSON field -> property
2020-04-07 10:16:10 +03:00
address(path: "$.city.altitude") # scalar JSON field -> property -> property
2019-03-25 16:45:35 +03:00
address(path: "city") # scalar JSON field -> property; '$.' prefix is optional
contacts(path: "[0]") # scalar JSON field -> array_item
2019-07-15 11:52:45 +03:00
contacts(path: "[0].phone") # scalar JSON field -> array_item_property
2020-04-20 11:55:09 +03:00
contacts(path: "['Hello world!']") # scalar JSON field -> property; used for special characters key
contacts(path: "[\"Hello world!\"]") # same as above; the syntax is ugly, but still works
2019-07-15 11:52:45 +03:00
2018-11-15 14:43:03 +03:00
article { # nested object
2018-09-11 14:11:24 +03:00
title
}
2019-07-15 11:52:45 +03:00
2018-11-15 14:43:03 +03:00
article_aggregate { # aggregate nested object
aggregate {
count
}
nodes {
title
}
}
2018-09-11 14:11:24 +03:00
}
2019-02-06 09:39:36 +03:00
.. _AggregateObject:
2018-12-17 14:58:29 +03:00
2019-09-11 10:17:14 +03:00
Aggregate object
2018-12-03 15:12:24 +03:00
***** ***** ***** *
2018-11-15 14:43:03 +03:00
.. code-block :: none
object-name_aggregate {
aggregate {
count
sum {
field
..
}
avg {
field
..
}
stddev {
field
..
}
stddev_samp {
field
..
}
stddev_pop {
field
..
}
variance {
field
..
}
var_samp {
field
..
}
var_pop {
field
..
}
max {
field
..
}
min {
field
..
}
nodes {
field1
field2
..
nested object1
nested object2
aggregate nested object1
..
}
}
2019-09-11 10:17:14 +03:00
(For more details on aggregate functions, refer to the `Postgres docs <https://www.postgresql.org/docs/current/functions-aggregate.html#FUNCTIONS-AGGREGATE-STATISTICS-TABLE> `__ ).
2018-11-15 14:43:03 +03:00
2020-06-19 16:20:56 +03:00
*Example*
2018-11-15 14:43:03 +03:00
.. code-block :: graphql
author_aggregate {
aggregate {
count # total count
sum {
id # sum aggregate on id
}
avg {
id # avg aggregate on id
}
stddev {
id # stddev aggregate on id
}
stddev_samp {
id # stddev_samp aggregate on id
}
stddev_pop {
id # stddev_pop aggregate on id
}
variance {
id # variance aggregate on id
}
var_samp {
id # var_samp aggregate on id
}
var_pop {
id # var_pop aggregate on id
}
max {
id # max aggregate on id
}
min {
id # min aggregate on id
}
}
nodes { # objects
id # scalar field
name # scalar field
article { # nested object
title
}
2019-02-06 09:39:36 +03:00
article_aggregate { # aggregate nested object
2018-11-15 14:43:03 +03:00
aggregate {
count
}
nodes {
title
}
}
}
}
2018-09-11 14:11:24 +03:00
Argument
^^^^^^^^
.. parsed-literal ::
2018-11-23 04:53:56 +03:00
DistinctOnExp_ | WhereExp_ | OrderByExp_ | PaginationExp_
.. _DistinctOnExp:
DistinctOnExp
2018-12-03 15:12:24 +03:00
***** ***** ***
2018-11-23 04:53:56 +03:00
.. parsed-literal ::
distinct_on: [ TableSelectColumnEnum_ ]
2020-06-19 16:20:56 +03:00
*Example*
.. code-block :: graphql
query {
article(distinct_on: title) {
title
content
}
}
2018-11-23 04:53:56 +03:00
TableSelectColumnEnum
"""""""""""""""""""""
.. code-block :: graphql
#example table_select_column enum for "article" table
enum article_select_column {
id
title
content
author_id
is_published
}
2018-09-11 14:11:24 +03:00
.. _WhereExp:
WhereExp
***** ***
.. parsed-literal ::
where: BoolExp_
2020-06-19 16:20:56 +03:00
*Example*
.. code-block :: graphql
query {
author(where: {rating: {_gt: 4}}) {
name
articles {
title
}
}
}
2018-09-11 14:11:24 +03:00
BoolExp
"""""""
.. parsed-literal ::
2019-04-17 16:37:42 +03:00
AndExp_ | OrExp_ | NotExp_ | TrueExp_ | ColumnExp_
2018-09-11 14:11:24 +03:00
2019-12-17 17:22:39 +03:00
.. _AndExp:
2018-09-11 14:11:24 +03:00
AndExp
######
.. parsed-literal ::
{
_and: [BoolExp_]
}
2020-10-05 17:19:22 +03:00
2020-06-19 16:20:56 +03:00
*Example*
.. code-block :: graphql
query {
article(where: {_and: [{rating: {_gt: 4}}, {published_on: {_gt: "2018-01-01"}}]}) {
title
content
}
}
2018-09-11 14:11:24 +03:00
2019-12-17 17:22:39 +03:00
.. admonition :: Syntactic sugar
You can simplify an `` _and `` expression by passing the sub-expressions separated by a `` , `` .
2021-01-05 10:17:09 +03:00
**First example: _and expression with different fields**
2019-12-17 17:22:39 +03:00
.. code-block :: graphql
{
_and: [
{ rating: { _gte: 4 } },
{ published_on: { _gte: "2018-01-01" } }
]
}
# can be simplified to:
{
rating: { _gte: 4 },
published_on: { _gte: "2018-01-01" }
}
2021-01-05 10:17:09 +03:00
**Second example: _and expression with same field**
.. code-block :: graphql
_and: [
{
rating: {
_gt: 1
}
},
{
rating: {
_lt: 5
}
}
]
# can be simplified to:
rating: {
_gt: 1,
_lt: 5
}
2019-12-17 17:22:39 +03:00
2021-01-12 09:30:30 +03:00
.. _OrExp:
2018-09-11 14:11:24 +03:00
OrExp
#####
.. parsed-literal ::
{
_or: [BoolExp_]
}
2020-06-19 16:20:56 +03:00
*Example*
.. code-block :: graphql
query {
article(where: {_or: [{rating: {_gt: 4}}, {is_published: {_eq: true}}]}) {
title
content
}
}
2019-12-17 17:22:39 +03:00
.. note ::
The `` _or `` operator expects an array of expressions as input. Passing an object to it will result in the
behaviour of the `` _and `` operator due to the way `GraphQL list input coercion <https://graphql.github.io/graphql-spec/June2018/#sec-Type-System.List> `_
behaves.
2020-06-19 16:20:56 +03:00
*Example:*
2019-12-17 17:22:39 +03:00
.. code-block :: graphql
{
_or: {
rating: { _gte: 4 },
published_on: { _gte: "2018-01-01" }
}
}
# will be coerced to:
{
_or: [
{
rating: { _gte: 4 },
published_on: { _gte: "2018-01-01" }
}
]
}
# which is equivalent to:
{
_or: [
_and: [
{ rating: { _gte: 4 } },
{ published_on: { _gte: "2018-01-01" } }
]
]
}
2018-09-11 14:11:24 +03:00
NotExp
######
.. parsed-literal ::
{
_not: BoolExp_
}
2020-06-19 16:20:56 +03:00
*Example*
.. code-block :: graphql
query {
article(where: {_not: {title: {_eq: ""}}} ) {
title
content
}
}
2019-04-17 16:37:42 +03:00
TrueExp
#######
.. parsed-literal ::
{}
2020-06-19 16:20:56 +03:00
*Example*
.. code-block :: graphql
query {
author(where: {articles: {}}) {
name
}
}
.. note ::
`` {} `` evaluates to true whenever an object exists (even if it's `` null `` ).
2018-09-11 14:11:24 +03:00
ColumnExp
#########
.. parsed-literal ::
{
field-name : {Operator_: Value }
}
2020-06-19 16:20:56 +03:00
*Example*
.. code-block :: graphql
query {
article(where: {title: {_eq: "GraphQL Tutorial"}}) {
title
content
}
}
2018-10-31 16:49:29 +03:00
.. _Operator:
2018-09-11 14:11:24 +03:00
Operator
########
2020-04-23 15:06:54 +03:00
.. _generic_operators:
2019-01-21 12:20:14 +03:00
**Generic operators (all column types except json, jsonb):**
2018-09-11 14:11:24 +03:00
2020-04-23 15:06:54 +03:00
.. list-table ::
:header-rows: 1
* - Operator
- PostgreSQL equivalent
* - `` _eq ``
- `` = ``
* - `` _neq ``
- `` <> ``
* - `` _gt ``
- `` > ``
* - `` _lt ``
2020-10-05 17:19:22 +03:00
- `` < ``
2020-04-23 15:06:54 +03:00
* - `` _gte ``
- `` >= ``
* - `` _lte ``
2020-10-05 17:19:22 +03:00
- `` <= ``
2020-04-23 15:06:54 +03:00
* - `` _in ``
- `` IN ``
* - `` _nin ``
2020-10-05 17:19:22 +03:00
- `` NOT IN ``
2020-04-23 15:06:54 +03:00
2020-07-09 11:42:33 +03:00
(For more details, refer to the Postgres docs for `comparison operators <https://www.postgresql.org/docs/current/functions-comparison.html> `__ and `list based search operators <https://www.postgresql.org/docs/current/functions-comparisons.html> `__ .)
2020-04-23 15:06:54 +03:00
.. _text_operators:
2018-09-11 14:11:24 +03:00
2019-02-06 09:39:36 +03:00
**Text related operators:**
2020-04-23 15:06:54 +03:00
.. list-table ::
:header-rows: 1
* - Operator
- PostgreSQL equivalent
* - `` _like ``
- `` LIKE ``
* - `` _nlike ``
- `` NOT LIKE ``
* - `` _ilike ``
- `` ILIKE ``
* - `` _nilike ``
- `` NOT ILIKE ``
* - `` _similar ``
- `` SIMILAR TO ``
* - `` _nsimilar ``
- `` NOT SIMILAR TO ``
2020-11-27 13:53:58 +03:00
* - `` _regex ``
- `` ~ ``
* - `` _iregex ``
- `` ~* ``
* - `` _nregex ``
- `` !~ ``
* - `` _niregex ``
- `` !~* ``
2020-04-23 15:06:54 +03:00
(For more details on text related operators, refer to the `Postgres docs <https://www.postgresql.org/docs/current/functions-matching.html> `__ .)
.. _null_expression:
2019-02-06 09:39:36 +03:00
**Checking for NULL values:**
2020-04-23 15:06:54 +03:00
.. list-table ::
:header-rows: 1
* - Operator
- PostgreSQL equivalent
* - `` _is_null `` (takes true/false as values)
- `` IS NULL ``
(For more details on the `` IS NULL `` expression, refer to the `Postgres docs <https://www.postgresql.org/docs/current/functions-comparison.html> `__ .)
.. _type_casting:
2019-02-06 09:39:36 +03:00
2019-07-15 11:52:45 +03:00
**Type casting:**
2020-04-23 15:06:54 +03:00
.. list-table ::
:header-rows: 1
* - Operator
- PostgreSQL equivalent
* - `` _cast `` (takes a CastExp_ as a value)
- `` :: ``
(For more details on type casting, refer to the `Postgres docs <https://www.postgresql.org/docs/current/sql-createcast.html> `__ .)
.. _jsonb_operators:
2019-07-15 11:52:45 +03:00
2019-01-21 12:20:14 +03:00
**JSONB operators:**
2018-09-11 14:11:24 +03:00
2018-09-20 12:51:27 +03:00
.. list-table ::
:header-rows: 1
* - Operator
- PostgreSQL equivalent
* - `` _contains ``
- `` @> ``
* - `` _contained_in ``
- `` <@ ``
* - `` _has_key ``
- `` ? ``
* - `` _has_keys_any ``
2020-04-23 15:06:54 +03:00
- `` ?! ``
2018-09-20 12:51:27 +03:00
* - `` _has_keys_all ``
- `` ?& ``
2020-04-23 15:06:54 +03:00
(For more details on JSONB operators, refer to the `Postgres docs <https://www.postgresql.org/docs/current/static/functions-json.html#FUNCTIONS-JSONB-OP-TABLE> `__ .)
.. _geometry_operators:
2018-09-11 14:11:24 +03:00
2019-01-21 12:20:14 +03:00
**PostGIS related operators on GEOMETRY columns:**
2019-01-17 09:21:38 +03:00
.. list-table ::
:header-rows: 1
* - Operator
- PostGIS equivalent
* - `` _st_contains ``
2020-04-23 15:06:54 +03:00
- `` ST_Contains(column, input) ``
2019-01-17 09:21:38 +03:00
* - `` _st_crosses ``
2020-04-23 15:06:54 +03:00
- `` ST_Crosses(column, input) ``
2019-01-17 09:21:38 +03:00
* - `` _st_equals ``
2020-04-23 15:06:54 +03:00
- `` ST_Equals(column, input) ``
2019-01-17 09:21:38 +03:00
* - `` _st_intersects ``
2020-04-23 15:06:54 +03:00
- `` ST_Intersects(column, input) ``
2019-01-17 09:21:38 +03:00
* - `` _st_overlaps ``
2020-04-23 15:06:54 +03:00
- `` ST_Overlaps(column, input) ``
2019-01-17 09:21:38 +03:00
* - `` _st_touches ``
2020-04-23 15:06:54 +03:00
- `` ST_Touches(column, input) ``
2019-01-17 09:21:38 +03:00
* - `` _st_within ``
2020-04-23 15:06:54 +03:00
- `` ST_Within(column, input) ``
2019-01-17 09:21:38 +03:00
* - `` _st_d_within ``
2020-04-23 15:06:54 +03:00
- `` ST_DWithin(column, input) ``
2019-01-17 09:21:38 +03:00
2020-04-23 15:06:54 +03:00
(For more details on spatial relationship operators, refer to the `PostGIS docs <http://postgis.net/workshops/postgis-intro/spatial_relationships.html> `__ .)
2019-01-17 09:21:38 +03:00
2019-01-21 12:20:14 +03:00
.. note ::
2019-02-06 09:39:36 +03:00
- All operators take a JSON representation of `` geometry/geography `` values as input value.
2019-09-11 10:17:14 +03:00
- The input value for `` _st_d_within `` operator is an object:
2019-01-17 09:21:38 +03:00
2019-02-06 09:39:36 +03:00
.. parsed-literal ::
2019-01-17 09:21:38 +03:00
{
field-name : {_st_d_within: {distance: Float, from: Value} }
}
2020-04-23 15:06:54 +03:00
.. _intersect_operators:
2019-08-29 16:07:05 +03:00
2020-04-23 15:06:54 +03:00
**Intersect Operators on RASTER columns:**
2019-08-29 16:07:05 +03:00
2020-04-23 15:06:54 +03:00
.. list-table ::
:header-rows: 1
2019-08-29 16:07:05 +03:00
2020-04-23 15:06:54 +03:00
* - Operator
- PostgreSQL equivalent
- Input object
* - `` _st_intersects_rast ``
- `` ST_Intersects(column, value) ``
- `` { _st_intersects_rast: raster } ``
* - `` _st_intersects_nband_geom ``
- `` ST_Intersects(column, nband, geommin) ``
- `` { _st_intersects_nband_geom: {nband: Integer! geommin: geometry!} ``
* - `` _st_intersects_geom_nband ``
- `` ST_Intersects(column, geommin, nband) ``
- `` { _st_intersects_geom_nband: {geommin: geometry! nband: Integer } ``
(For more details on intersect operators on `` raster `` columns refer to the `PostGIS docs <https://postgis.net/docs/RT_ST_Intersects.html> `__ .)
2019-08-29 16:07:05 +03:00
2021-02-25 17:10:18 +03:00
.. _ltree_operators:
**ltree operators:**
.. list-table ::
:header-rows: 1
* - Operator
- PostgreSQL equivalent
* - `` _ancestor ``
- `` @> ``
* - `` _ancestor_any ``
- `` @> ``
* - `` _descendant ``
- `` <@ ``
* - `` _descendant_any ``
- `` <@ ``
* - `` _matches ``
- `` ~ ``
* - `` _matches_any ``
- `` ? ``
* - `` _matches_fulltext ``
- `` @ ``
(For more details on operators on `` ltree `` columns refer to the `Postgres docs <https://www.postgresql.org/docs/current/ltree.html> `__ .)
2019-07-15 11:52:45 +03:00
.. _CastExp:
CastExp
#######
.. parsed-literal ::
{type-name: {Operator_: Value}}
2020-06-19 16:20:56 +03:00
*Example*
.. code-block :: graphql
query MyQuery($coordinate: geography!) {
postgis_test_table(
where: {
geometry_column: {
_cast: {
geography: { _st_d_within: { distance: 1000000, from: $coordinate } }
}
}
}
) {
id
}
}
2020-10-05 17:19:22 +03:00
2020-06-19 16:20:56 +03:00
Variables:
{
"coordinate": {
"type": "Point",
"coordinates": [ 2.5559, 49.0083 ]
}
}
2019-07-15 11:52:45 +03:00
.. note ::
Currently, only casting between `` geometry `` and `` geography `` types is allowed.
2018-09-11 14:11:24 +03:00
.. _OrderByExp:
OrderByExp
***** *****
.. parsed-literal ::
2018-10-26 14:57:33 +03:00
order_by: (TableOrderBy_ | [ TableOrderBy_ ])
2018-09-11 14:11:24 +03:00
2020-06-19 16:20:56 +03:00
*Example 1*
2018-09-11 14:11:24 +03:00
2020-06-19 16:20:56 +03:00
.. code-block :: graphql
2018-09-11 14:11:24 +03:00
2020-06-19 16:20:56 +03:00
query {
author(order_by: {rating: desc}) {
name
rating
}
}
2018-09-11 14:11:24 +03:00
2020-06-19 16:20:56 +03:00
*Example 2*
2018-09-11 14:11:24 +03:00
2020-06-19 16:20:56 +03:00
.. code-block :: graphql
2018-10-26 14:57:33 +03:00
2020-06-19 16:20:56 +03:00
query {
article(order_by: [{id: desc}, {author: {id: asc}}]) {
title
rating
}
}
2018-10-26 14:57:33 +03:00
2020-06-19 16:20:56 +03:00
*Example 3*
2018-12-12 15:58:39 +03:00
2020-06-19 16:20:56 +03:00
.. code-block :: graphql
2018-12-12 15:58:39 +03:00
2020-06-19 16:20:56 +03:00
query {
article(order_by: [{id: desc}, {author: {id: asc}}]) {
title
rating
}
}
2018-12-12 15:58:39 +03:00
2018-10-26 14:57:33 +03:00
TableOrderBy
2019-02-06 09:39:36 +03:00
""""""""""""
2018-10-26 14:57:33 +03:00
2020-06-19 16:20:56 +03:00
**For columns**
2018-10-26 14:57:33 +03:00
.. parsed-literal ::
{column: OrderByEnum_}
2020-06-19 16:20:56 +03:00
*Example*
.. code-block :: graphql
query {
article(order_by: {rating: asc}) {
title
content
}
}
**For object relations**
2018-10-26 14:57:33 +03:00
.. parsed-literal ::
{relation-name: TableOrderBy_}
2020-06-19 16:20:56 +03:00
*Example*
.. code-block :: graphql
query {
article(order_by: {author: {rating: desc}}) {
title
content
}
}
**For array relations aggregate**
2018-12-12 15:58:39 +03:00
.. parsed-literal ::
{relation-name_aggregate: AggregateOrderBy_}
2020-06-19 16:20:56 +03:00
*Example*
2018-10-26 14:57:33 +03:00
2020-06-19 16:20:56 +03:00
.. code-block :: graphql
query {
author(order_by: {articles_aggregate: {max: {rating: asc}}}) {
name
}
}
Order by type for `` article `` table:
2018-10-26 14:57:33 +03:00
2018-09-11 14:11:24 +03:00
.. code-block :: graphql
2018-10-26 14:57:33 +03:00
input article_order_by {
id: order_by
title: order_by
content: order_by
author_id: order_by
#order by using "author" object relationship columns
author: author_order_by
2018-12-12 15:58:39 +03:00
#order by using "likes" array relationship aggregates
likes_aggregate: likes_aggregate_order_by
2020-10-05 17:19:22 +03:00
}
2020-06-19 16:20:56 +03:00
.. _OrderByEnum:
2018-09-11 14:11:24 +03:00
2018-10-26 14:57:33 +03:00
OrderByEnum
2019-02-06 09:39:36 +03:00
###########
2018-09-11 14:11:24 +03:00
2018-10-26 14:57:33 +03:00
.. code-block :: graphql
#the order_by enum type
enum order_by {
2018-11-22 07:58:18 +03:00
#in the ascending order, nulls last
2018-10-26 14:57:33 +03:00
asc
2018-11-22 07:58:18 +03:00
#in the ascending order, nulls last
asc_nulls_last
2018-10-26 14:57:33 +03:00
#in the ascending order, nulls first
asc_nulls_first
#in the descending order, nulls first
2018-11-22 07:58:18 +03:00
desc
#in the descending order, nulls first
2018-10-26 14:57:33 +03:00
desc_nulls_first
2018-11-22 07:58:18 +03:00
#in the descending order, nulls last
desc_nulls_last
2018-10-26 14:57:33 +03:00
}
2018-09-11 14:11:24 +03:00
2019-03-25 16:45:35 +03:00
AggregateOrderBy
2019-02-06 09:39:36 +03:00
################
2020-06-19 16:20:56 +03:00
**Count aggregate**
2019-02-06 09:39:36 +03:00
.. parsed-literal ::
{count: OrderByEnum_}
2020-06-19 16:20:56 +03:00
*Example*
.. code-block :: graphql
query {
author(order_by: {articles_aggregate: {count: desc}}) {
name
}
}
**Operation aggregate**
2019-02-06 09:39:36 +03:00
.. parsed-literal ::
{op_name: TableAggOpOrderBy_}
2020-06-19 16:20:56 +03:00
*Example*
.. code-block :: graphql
query {
author (order_by: {articles_aggregate: {sum: {id: desc}}}) {
id
}
}
2019-02-06 09:39:36 +03:00
Available operations are `` sum `` , `` avg `` , `` max `` , `` min `` , `` stddev `` , `` stddev_samp `` ,
2019-09-11 10:17:14 +03:00
`` stddev_pop `` , `` variance `` , `` var_samp `` and `` var_pop `` .
2019-02-06 09:39:36 +03:00
TableAggOpOrderBy
&&&&&&&&&&&&&&&&&
.. parsed-literal ::
{column: OrderByEnum_}
2018-09-11 14:11:24 +03:00
.. _PaginationExp:
PaginationExp
***** ***** ***
.. parsed-literal ::
2018-10-26 05:59:36 +03:00
limit: Integer
[offset: Integer]
2020-06-19 16:20:56 +03:00
*Example*
.. code-block :: graphql
query {
article(limit: 6, offset: 2) {
title
content
}
}