Skip to main content
Version: v2.x

Hasura - CockroachDB Compatibility

Introduction

As CockroachDB supports PostgreSQL, the way it functions with Hasura is also very similar. However, there are a few incompatibilities to be aware of.

Incompatibilities and unsupported features

The most up-to-date list of unsupported Postgres features can be found on the CockroachDB website.

Currently, the following features are supported with CockroachDB and Hasura:

Queries

Queries are fully supported, but please note that GraphQL key ordering in JSON objects is not guaranteed. This is because CockroachDB implements the JSONB variant of the Postgres JSON types, which do not preserve key ordering.

Please also note that SERIAL columns will produce numbers that overflow JavaScript numbers. These will need special treatment by either enabling the HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES environment variable or bespoke JSON parsing client-side.

Tables

Querying from all kinds of tables and views is currently supported. This includes local, reference, and distributed tables. All the tables can be tracked from the Hasura Console.

Relationships

The following table describes the supported relationships based on the supported joins in CockroachDB:

To LocalTo ReferenceTo Distributed
From LocalObject, ArrayObject, Array
From ReferenceObject, ArrayObject, Array
From DistributedObjectObject, Array

The Hasura Console allows you to add all the supported relationships.

Permissions

All permissions work on CockroachDB like on Postgres without any restrictions.

Functions

CockroachDB, and therefore Hasura, does not yet support user-defined functions (UDFs) on a stable release. However, UDF support has recently been added to CockroachDB Beta (see issue), so watch this space!

Mutations

Mutations are supported in GraphQL Engine with the exception of fetching relationship data as part of returning. This is not yet supported.

Subscriptions

Live Queries and Streaming Subscriptions are supported with CockroachDB.

Event Triggers

CockroachDB does not yet support creating triggers (see issue) on reference tables. Hence, this is currently not supported.

Naming conventions

Naming conventions are currently only implemented as an experimental feature on Postgres sources. See docs.