API Reference - Supported PostgreSQL Types

List of PostgreSQL types supported by the Hasura GraphQL engine with their equivalent Hasura types:

Name Aliases Description Hasura Type
bigint int8 signed eight-byte integer String
bigserial serial8 autoincrementing eight-byte integer String
bit [ (n) ]   fixed-length bit string Implicit
bit varying [ (n) ] varbit [ (n) ] variable-length bit string Implicit
boolean bool logical Boolean (true/false) Bool
box   rectangular box on a plane Implicit
bytea   binary data (“byte array”) Implicit
character [ (n) ] char [ (n) ] fixed-length character string Char
character varying [ (n) ] varchar [ (n) ] variable-length character string String
cidr   IPv4 or IPv6 network address Implicit
circle   circle on a plane Implicit
date   calendar date (year, month, day) Date
double precision float8 double precision floating-point number (8 bytes) Float
inet   IPv4 or IPv6 host address Implicit
integer int, int4 signed four-byte integer Int
interval [ fields ] [ (p) ]   time span Implicit
json   textual JSON data JSON
jsonb   binary JSON data, decomposed JSONB
line   infinite line on a plane Implicit
lseg   line segment on a plane Implicit
macaddr   MAC (Media Access Control) address Implicit
macaddr8   MAC (Media Access Control) address (EUI-64 format) Implicit
money   currency amount Implicit
numeric [ (p, s) ] decimal [ (p, s) ] exact numeric of selectable precision Numeric
path   geometric path on a plane Implicit
pg_lsn   PostgreSQL Log Sequence Number Implicit
point   geometric point on a plane Implicit
polygon   closed geometric path on a plane Implicit
real float4 single precision floating-point number (4 bytes) Float
smallint int2 signed two-byte integer Int
smallserial serial2 autoincrementing two-byte integer Int
serial serial4 autoincrementing four-byte integer Int
text   variable-length character string String
time [ (p) ] [ without time zone ]   time of day (no time zone) Implicit
time [ (p) ] with time zone timetz time of day, including time zone Timetz
timestamp [ (p) ] [ without time zone ]   date and time (no time zone) Implicit
timestamp [ (p) ] with time zone timestamptz date and time, including time zone Timestamptz
tsquery   text search query Implicit
tsvector   text search document Implicit
txid_snapshot   user-level transaction ID snapshot Implicit
uuid   universally unique identifier Implicit
xml   XML data Implicit

Int

GraphQL default scalar with name Int.

E.g.

objects: [
  {
    id: 1,
    int_col: 27
  }
]

Float

GraphQL custom scalar type with name float8.

E.g.

objects: [
  {
    id: 1,
    float_col: 0.8
  }
]

Numeric

GraphQL custom scalar type with name numeric.

E.g.

objects: [
  {
    id: 1,
    numeric_col: 0.00000008
  }
]

Bool

GraphQL default Scalar with name Boolean. The Boolean scalar type represents true or false.

E.g.

objects: [
  {
    id: 1,
    is_published: true
  }
]

Char

GraphQL custom scalar with name character. It is a String with single character.

E.g.

objects: [
  {
    id: 1,
    char_column: "a"
  }
]

String

GraphQL default scalar with name String. The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

E.g.

objects: [
  {
    id: 1,
    name: "Raven"
  }
]

Date

GraphQL custom scalar with name date. Date (no time of day). Allowed values are yyyy-mm-dd.

E.g.

objects: [
  {
    id: 1,
    date: "1996-03-15"
  }
]

Time with time zone

GraphQL custom scalar type with name timetz. 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).

E.g.

objects: [
  {
    id: 1,
    time: "17:30:15+05:30"
  }
]

Timestamp with time zone

GraphQL custom scalar type with name timestamptz. 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).

E.g.

objects: [
  {
    id: 1,
    timestamptz_col: "2016-07-20T17:30:15+05:30"
  }
]

JSON

GraphQL custom scalar type with name json. It is a stringified json value.

E.g.

objects: [
  {
    id: 1,
    json_col: "{ \"name\": \"raven\" }"
  }
]

JSONB

GraphQL custom scalar type with name jsonb. Value should be given through a variable of type jsonb.

E.g.

mutation insert_test($value : jsonb) {
  insert_test(
    objects: [
      {
        id: 1,
        jsonb_col: $value
      }
    ]
  ) {
     affected_rows
     returning{
       id
       details
     }
  }
}

variable:

{
  "value": {
    "name": "raven"
  }
}

Implicitly Supported types

All Implicit types in the above table are implicitly supported by GraphQL Engine. You have to provide the value in String.

E.g. For time without time zone type

In ISO 8601 format

objects: [
  {
    id: 1,
    time_col: "04:05:06.789"
  }
]

E.g. For macaddr type

objects: [
  {
    id: 1,
    macaddr_col: "08:00:2b:01:02:03"
  }
]

Note

You can learn more about PostgreSQL data types here