Configures Hasura for the indexer app. This is used as a part of DappetizerConfigUsingDb.

Example

Sample usage (all properties specified explicitly) within dappetizer.config.ts file:

import { DappetizerConfigUsingDb } from '@tezos-dappetizer/database';

const config: DappetizerConfigUsingDb = {
hasura: {
dropExistingTracking: false,
autotrackEntities: true,
url: 'http://localhost:8080',
adminSecret: 'secret',
customMappings: [
{
tableName: 'current_balance', // useful for views tracking
graphQLTypeName: 'CurrentBalance',
graphQLFieldName: 'currentBalance',
columns: [
{ columnName: 'owner_address', graphQLName: 'ownerAddress' },
{ columnName: 'amount', graphQLName: 'amount' },
{ columnName: 'token_id', graphQLName: 'tokenId' },
],
relationships: [
{
name: 'token',
type: 'manyToOne',
columns: ['token_id'],
referencedTableName: 'token',
referencedColumns: ['id'],
},
],
}
],
autotrackedMappings: [
{
entityName: 'DbAction',
graphQLTypeName: 'Action',
graphQLFieldName: 'action',
columns: [
{ propertyName: 'type', graphQLName: 'actionType' },
],
},
{
entityName: 'DbToken',
graphQLTypeName: 'Token',
graphQLFieldName: 'token',
},
{
entityName: 'DbContract',
graphQLTypeName: 'Contract',
graphQLFieldName: 'contract',
relationships: [
{
name: 'tokens',
type: 'oneToMany',
columns: ['address'],
referencedTableName: 'token',
referencedColumns: ['contract_address'],
},
{
name: 'contractFeatures',
type: 'oneToMany',
columns: ['address'],
referencedTableName: 'contract_feature',
referencedColumns: ['contract_address'],
},
],
},
],
selectLimit: 1000,
allowAggregations: true,
namingStyle: 'noTransformation',
},
... // Other config parts.
};

export default config;

Hierarchy

  • HasuraDappetizerConfig

Properties

adminSecret?: string

The admin secret password for Hasura metadata endpoint. Will be used as 'x-hasura-admin-secret' http header.

Default

undefined

allowAggregations?: boolean

Boolean indicating if aggregation should be added into graphql schema.

Default

true

autotrackEntities?: boolean

Boolean indicating if Hasura initializer should automatically track existing entities.

Default

false

autotrackedMappings?: {
    columns?: {
        graphQLName?: string;
        hidden?: boolean;
        propertyName: string;
    }[];
    entityName: string;
    graphQLAggregateFieldName?: string;
    graphQLFieldName?: string;
    graphQLPluralFieldName?: string;
    graphQLTypeName?: string;
    relationships?: {
        columns: string[];
        name: string;
        referencedColumns: string[];
        referencedTableName: string;
        type?: "oneToMany" | "manyToOne";
    }[];
    skipped?: boolean;
}[]

The entity and column names overrides, additional relationships definitions when autotracking used.

customMappings?: {
    columns?: {
        columnName: string;
        graphQLName?: string;
        hidden?: boolean;
    }[];
    graphQLAggregateFieldName?: string;
    graphQLFieldName: string;
    graphQLPluralFieldName?: string;
    graphQLTypeName: string;
    relationships?: {
        columns: string[];
        name: string;
        referencedColumns: string[];
        referencedTableName: string;
        type?: "oneToMany" | "manyToOne";
    }[];
    tableName: string;
}[]

The custom mapping of tables, columns and relationships definitions. Useful especially for tracking and configuring views.

dropExistingTracking?: boolean

Boolean indicating if Hasura metadata (tracking tables and relationships, and permissions) should be cleared before its recreation.

Default

false

namingStyle?: "noTransformation" | "snakeCase"

Naming style for generated graphql schema relationships.

Limits

A value 'noTransformation' or 'snakeCase'.

Default

'noTransformation'

selectLimit?: number

Number indicating limit of rows returned by graphql query.

Limits

An integer with minimum 1.

Default

100

source?: string

The Hasura database source.

Default

'default'

url?: string

The url where Hasura endpoints are available on.

Limits

An absolute URL string.

Default

undefined (no Hasura is used)

Generated using TypeDoc