2020-01-14 15:57:45 +03:00
.. meta ::
:description: Common syntax definitions for the Hasura schema/metadata API
:keywords: hasura, docs, schema/metadata API, API reference, syntax definitions
2020-03-11 22:42:36 +03:00
.. _api_metadata_syntax_defs:
2019-07-10 13:19:58 +03:00
Schema/Metadata API Reference: Common syntax definitions
========================================================
2018-10-08 17:12:03 +03:00
2018-12-03 15:12:24 +03:00
.. contents :: Table of contents
:backlinks: none
:depth: 1
:local:
2018-10-08 17:12:03 +03:00
.. _TableName:
TableName
^^^^^^^^^
.. parsed-literal ::
2018-10-17 08:27:11 +03:00
:class: haskell-pre
2018-10-08 17:12:03 +03:00
2018-10-17 08:27:11 +03:00
String | QualifiedTable_
2020-03-03 15:02:40 +03:00
.. _QualifiedTable:
2018-10-17 08:27:11 +03:00
QualifiedTable
^^^^^^^^^^^^^^
2019-01-25 06:31:54 +03:00
.. parsed-literal ::
:class: haskell-pre
{
2020-01-13 10:11:30 +03:00
"name": String,
"schema": String
2019-01-25 06:31:54 +03:00
}
.. _FunctionName:
FunctionName
^^^^^^^^^^^^
.. parsed-literal ::
:class: haskell-pre
String | QualifiedFunction_
QualifiedFunction
^^^^^^^^^^^^^^^^^
2018-10-17 08:27:11 +03:00
.. parsed-literal ::
:class: haskell-pre
{
2020-01-13 10:11:30 +03:00
"name": String,
"schema": String
2018-10-17 08:27:11 +03:00
}
2018-10-08 17:12:03 +03:00
.. _RoleName:
RoleName
^^^^^^^^
2019-10-18 11:29:47 +03:00
.. parsed-literal ::
String
.. _ComputedFieldName:
ComputedFieldName
^^^^^^^^^^^^^^^^^^
2018-10-08 17:12:03 +03:00
.. parsed-literal ::
String
.. _PGColumnType:
PGColumnType
^^^^^^^^^^^^
.. parsed-literal ::
String
1. Numeric types
.. list-table ::
:widths: 12 10 20
:header-rows: 1
* - Type
- Alias
- Description
* - `` serial ``
-
- autoincrementing integer
* - `` bigserial ``
-
- autoincrementing bigint
* - `` integer ``
-
- 4 bytes, typical choice for integer
* - `` smallint ``
-
- 2 bytes
* - `` bigint ``
-
- 8 bytes
* - `` real ``
- `` float4 ``
- 6 decimal digits precision, inexact
* - `` double precision ``
- `` float8 ``
- 15 decimal digits precision, inexact
* - `` numeric ``
- `` decimal ``
- arbitrary precision, exact
2. Character types
.. list-table ::
:widths: 8 6 20
:header-rows: 1
* - Type
- Alias
- Description
* - `` varchar ``
- `` text ``
- typical choice for storing string types
3. Date/Time types
.. list-table ::
:widths: 8 6 20
:header-rows: 1
* - Type
- Alias
- Description
* - `` timestamp with time zone ``
- `` timestamptz ``
2018-10-15 11:47:21 +03:00
- both date and time, with time zone. Allowed values should be of ISO8601 format. E.g. 2016-07-20T17:30:15Z, 2016-07-20T17:30:15+05:30, 2016-07-20T17:30:15.234890+05:30
2018-10-08 17:12:03 +03:00
* - `` time with time zone ``
- `` timetz ``
2018-10-15 11:47:21 +03:00
- time of day only, with time zone. Allowed values should be of ISO8601 format. E.g. 17:30:15Z, 17:30:15+05:30, 17:30:15.234890+05:30
2018-10-08 17:12:03 +03:00
* - `` date ``
-
- date (no time of day). Allowed values are yyyy-mm-dd
4. Boolean type
.. list-table ::
:widths: 8 6 20
:header-rows: 1
* - Type
- Alias
- Description
* - `` boolean ``
-
- state of true or false
5. JSON types
.. list-table ::
:widths: 8 6 20
:header-rows: 1
* - Type
- Alias
- Description
* - `` json ``
-
- Stored as plain text
* - `` jsonb ``
-
- Stored in a binary format and can be indexed
.. _PGColumn:
PGColumn
^^^^^^^^
.. parsed-literal ::
String
.. _RelationshipName:
RelationshipName
^^^^^^^^^^^^^^^^
.. parsed-literal ::
String
.. _BoolExp:
BoolExp
^^^^^^^
.. parsed-literal ::
:class: haskell-pre
2019-09-05 10:34:53 +03:00
AndExp_ | OrExp_ | NotExp_ | ExistsExp_ | TrueExp_ | ColumnExp_
2018-10-08 17:12:03 +03:00
AndExp
^^^^^^
.. parsed-literal ::
:class: haskell-pre
{
"$and" : [BoolExp_],
}
OrExp
^^^^^
.. parsed-literal ::
:class: haskell-pre
{
"$or" : [BoolExp_],
}
NotExp
^^^^^^
.. parsed-literal ::
:class: haskell-pre
{
"$not" : BoolExp_
}
2019-09-05 10:34:53 +03:00
ExistsExp
^^^^^^^^^
.. parsed-literal ::
:class: haskell-pre
{
"$exists" : {
"_table": TableName_,
"_where": BoolExp_
}
}
2019-04-17 16:37:42 +03:00
TrueExp
^^^^^^^
.. parsed-literal ::
:class: haskell-pre
{}
2018-10-08 17:12:03 +03:00
ColumnExp
^^^^^^^^^
.. parsed-literal ::
:class: haskell-pre
{
PGColumn_ : { Operator_ : Value }
}
2019-07-29 12:28:27 +03:00
.. _MetadataOperator:
2018-10-08 17:12:03 +03:00
Operator
^^^^^^^^
2019-07-10 13:19:58 +03:00
**Generic operators (all column types except json, jsonb) :**
2018-10-08 17:12:03 +03:00
2020-04-23 15:06:54 +03:00
.. list-table ::
:header-rows: 1
* - Operator
- PostgreSQL equivalent
* - `` "$eq" ``
- `` = ``
* - `` "$ne" ``
- `` <> ``
* - `` "$gt" ``
- `` > ``
* - `` "$lt" ``
- `` < ``
* - `` "$gte" ``
- `` >= ``
* - `` "$lte" ``
- `` <= ``
* - `` "$in" ``
- `` IN ``
* - `` "$nin" ``
- `` NOT IN ``
(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> `_ .)
2018-10-08 17:12:03 +03:00
2019-07-10 13:19:58 +03:00
**Text related operators :**
2018-10-08 17:12:03 +03:00
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 ``
(For more details on text related operators, refer to the `Postgres docs <https://www.postgresql.org/docs/current/functions-matching.html> `__ .)
2018-10-08 17:12:03 +03:00
2019-07-10 13:19:58 +03:00
**Operators for comparing columns (all column types except json, jsonb):**
2018-10-08 17:12:03 +03:00
2020-04-23 15:06:54 +03:00
.. list-table ::
:header-rows: 1
* - Operator
- PostgreSQL equivalent
* - `` "$ceq" ``
- `` = ``
* - `` "$cne" ``
- `` <> ``
* - `` "$cgt" ``
- `` > ``
* - `` "$clt" ``
- `` < ``
* - `` "$cgte" ``
- `` >= ``
* - `` "$clte" ``
- `` <= ``
(For more details on comparison operators, refer to the `Postgres docs <https://www.postgresql.org/docs/current/functions-comparison.html> `__ .)
2018-10-08 17:12:03 +03:00
2019-07-10 13:19:58 +03:00
**Checking for NULL values :**
2019-02-15 15:48:18 +03:00
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> `__ .)
2019-02-15 15:48:18 +03:00
2019-07-10 13:19:58 +03:00
**JSONB operators :**
2019-02-15 15:48:18 +03:00
.. list-table ::
:header-rows: 1
* - Operator
- PostgreSQL equivalent
* - `` _contains ``
- `` @> ``
* - `` _contained_in ``
- `` <@ ``
* - `` _has_key ``
- `` ? ``
2019-07-10 13:19:58 +03:00
* - `` _has_keys_any ``
2020-04-23 15:06:54 +03:00
- `` ?! ``
2019-07-10 13:19:58 +03:00
* - `` _has_keys_all ``
- `` ?& ``
2019-02-15 15:48:18 +03:00
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> `__ .)
2019-07-10 13:19:58 +03:00
**PostGIS related operators on GEOMETRY columns:**
2019-02-15 15:48:18 +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-02-15 15:48:18 +03:00
* - `` _st_crosses ``
2020-04-23 15:06:54 +03:00
- `` ST_Crosses(column, input) ``
2019-02-15 15:48:18 +03:00
* - `` _st_equals ``
2020-04-23 15:06:54 +03:00
- `` ST_Equals(column, input) ``
2019-02-15 15:48:18 +03:00
* - `` _st_intersects ``
2020-04-23 15:06:54 +03:00
- `` ST_Intersects(column, input) ``
2019-02-15 15:48:18 +03:00
* - `` _st_overlaps ``
2020-04-23 15:06:54 +03:00
- `` ST_Overlaps(column, input) ``
2019-02-15 15:48:18 +03:00
* - `` _st_touches ``
2020-04-23 15:06:54 +03:00
- `` ST_Touches(column, input) ``
2019-02-15 15:48:18 +03:00
* - `` _st_within ``
2020-04-23 15:06:54 +03:00
- `` ST_Within(column, input) ``
2019-02-15 15:48:18 +03:00
* - `` _st_d_within ``
2020-04-23 15:06:54 +03:00
- `` ST_DWithin(column, input) ``
2019-02-15 15:48:18 +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-02-15 15:48:18 +03:00
.. note ::
- 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-02-15 15:48:18 +03:00
.. parsed-literal ::
{
field-name : {_st_d_within: {distance: Float, from: Value} }
}
2018-10-08 17:12:03 +03:00
.. _Object:
Object
^^^^^^
A JSONObject_
.. parsed-literal ::
:class: haskell-pre
{
"k1" : v1,
"k2" : v2,
..
}
.. _JSONObject: https://tools.ietf.org/html/rfc7159
2019-04-01 11:58:39 +03:00
2019-04-17 19:29:39 +03:00
.. _Empty Object:
Empty Object
^^^^^^^^^^^^
An empty JSONObject_
.. code-block :: json
{}
2019-04-01 11:58:39 +03:00
.. _ColumnPresetExp:
ColumnPresetsExp
^^^^^^^^^^^^^^^^
2019-09-11 10:17:14 +03:00
A JSONObject_ of a Postgres column name to value mapping, where the value can be static or derived from a session variable.
2019-04-01 11:58:39 +03:00
.. parsed-literal ::
:class: haskell-pre
{
"column1" : colVal1,
"column2" : colVal2,
..
}
2019-09-11 10:17:14 +03:00
E.g. where `` id `` is derived from a session variable and `` city `` is a static value.
2019-04-01 11:58:39 +03:00
.. code-block :: json
{
2019-05-16 09:13:25 +03:00
"id" : "x-hasura-User-Id",
2019-04-01 11:58:39 +03:00
"city" : "San Francisco"
}
.. note ::
If the value of any key begins with "x-hasura-" (*case-insensitive* ), the value of the column specified in the key will be derived from a session variable of the same name.
2019-05-16 09:13:25 +03:00
2019-07-08 08:51:41 +03:00
.. _RemoteSchemaName:
RemoteSchemaName
^^^^^^^^^^^^^^^^
.. parsed-literal ::
String
.. _RemoteSchemaDef:
RemoteSchemaDef
^^^^^^^^^^^^^^^
.. parsed-literal ::
:class: haskell-pre
{
"url" : url-string,
"url_from_env" : env-var-string,
"headers": [
{ "name": header-name-string,
"value": header-value-string,
"value_from_env": env-var-string
}
],
2019-08-23 11:57:19 +03:00
"forward_client_headers": boolean,
"timeout_seconds": integer
2019-07-08 08:51:41 +03:00
}
2019-05-16 09:13:25 +03:00
.. _CollectionName:
CollectionName
^^^^^^^^^^^^^^
.. parsed-literal ::
String
.. _QueryName:
QueryName
^^^^^^^^^
.. parsed-literal ::
String
.. _CollectionQuery:
CollectionQuery
^^^^^^^^^^^^^^^
.. parsed-literal ::
:class: haskell-pre
{
"name": String,
"query": String
}
2019-09-19 07:47:36 +03:00
.. _CustomColumnNames:
CustomColumnNames
^^^^^^^^^^^^^^^^^^
A JSONObject_ of Postgres column name to GraphQL name mapping
.. parsed-literal ::
:class: haskell-pre
{
"column1" : String,
"column2" : String,
..
}
2020-02-13 20:38:23 +03:00
.. _ActionName:
ActionName
^^^^^^^^^^
.. parsed-literal ::
:class: haskell-pre
String
.. _WebhookURL:
WebhookURL
^^^^^^^^^^
A String value which supports templating environment variables enclosed in `` {{ `` and `` }} `` .
.. parsed-literal ::
:class: haskell-pre
String
Template example: `` https://{{ACTION_API_DOMAIN}}/create-user ``
.. _HeaderFromValue:
HeaderFromValue
^^^^^^^^^^^^^^^
.. list-table ::
:header-rows: 1
* - Key
- required
- Schema
- Description
* - name
- true
- String
- Name of the header
* - value
- true
- String
- Value of the header
.. _HeaderFromEnv:
HeaderFromEnv
^^^^^^^^^^^^^
.. list-table ::
:header-rows: 1
* - Key
- required
- Schema
- Description
* - name
- true
- String
- Name of the header
* - value_from_env
- true
- String
- Name of the environment variable which holds the value of the header
.. _GraphQLType:
GraphQLType
^^^^^^^^^^^
A GraphQL `Type Reference <https://spec.graphql.org/June2018/#sec-Type-References> `__ string.
.. parsed-literal ::
:class: haskell-pre
String
Example: `` String! `` for non-nullable String type and `` [String] `` for array of String types
.. _GraphQLName:
GraphQLName
^^^^^^^^^^^
A string literal that conform to `GraphQL spec <https://spec.graphql.org/June2018/#Name> `__ .
.. parsed-literal ::
:class: haskell-pre
String