Skip to main content
Entities are defined by root-level GraphQL types decorated with @entity. Names and properties of entities are expected to be camelCased. They are converted into snake_case for use as the corresponding database table and column names. The primary key column is always mapped to the entity field of a special ID type mapped as string (varchar). Non-nullable fields are marked with an exclamation mark (!) and are nullable otherwise. The following scalar types are supported by the schema.graphql dialect:
  • String (mapped to text)
  • Int (mapped to int4)
  • Float (mapped to numeric, ts type number)
  • Boolean (mapped to bool)
  • DateTime (mapped to timestamptz, ts type Date)
  • BigInt (mapped to numeric, ts type bigint)
  • BigDecimal (mapped to numeric, ts type BigDecimal of @subsquid/big-decimal)
  • Bytes (mapped to bytea, ts type Uint8Array)
  • JSON (mapped to jsonb, ts type unknown)
  • Enums (mapped to a length-bounded varchar column)
  • User-defined scalars (non-entity types). Such properties are mapped as jsonb columns.
Example

Arrays

An entity field can be an array of any scalar type except BigInt and BigDecimal. It will be mapped to the corresponding Postgres array type. Array elements may be defined as nullable or non-nullable. Example