
Setup Sequin
To use Hasura with Sequin, you need to sync to a self-hosted database. A Sequin-hosted demo database isn’t configured with the permissions required to connect to Hasura.
Setup Hasura
Step 1: Create a new Hasura Cloud project. If you don’t have one already, you can sign up for a free account. Step 2: Connect your database to Hasura. You can do this by selecting Postgres and then clicking the Connect Existing Database button in the Hasura dashboard. Enter your database connection details and click Connect Database. If you need more details, read the Hasura docs. Step 3: Once Hasura connects to your database, it will appear in the Data Manager. Next, you can configure Hasura to track the tables in your database. Select your database and the schema containing the tables you want to track. Then, click the Track button next to each table you want to query via Hasura. Do this for both yourpublic
schema and your Sequin schema.

You don’t need to track Sequin system tables that start with
_sync
.Configure relationships
Hasura uses relationships to join tables together when executing GraphQL queries. Because your Sequin schema doesn’t contain foreign keys, you’ll manually configure relationships in the Hasura dashboard or using the Hasura CLI. Step 1: To configure relationships in the Hasura dashboard, select the table you want to define a relationship for in the Data Manager, click the Relationships tab, and then click the Add Relationship button. Step 2: Give the relationship a name (e.g.,deal_associations
), select the table you want to join to, and then select the columns you want to join on. Then click the Create Relationship button:

Direct relationships
For sources like Salesforce and Stripe, you’ll often create a relationship between two tables by simply mapping the primary key of one table to the foreign key of the other table. For example, if you want to join theaccount
table to the opportunity
table, you would map the account_id
column in the opportunity
table to the id
column in the account
table.

- On the
account
table you’ll create an object relationship betweenaccount.id
andopportunity.account_id
. - On the
opportunity
table you’ll create an array relationship between opportunityopportunity.account_id
andaccount.id
.
Join table relationships
For sources like HubSpot, you’ll often need to create a relationship between two tables using anassociations
join table. For example, if you want to join the deal
table to the contact
table, you’ll sync a join table called associations_contact_deal
that contains the relationship between deal_id
and contact_id
. Then, you would map the deal_id
column in the associations_contact_deal
join table to the id
column in the deal
table and the contact_id
column in the associations_contact_deal
table to the id
column in the contact
table.

- On the
associations_contact_deal
table you’ll create an object relationship betweenassociations_contact_deal.contact_id
andcontact.id
. You can call thisassociations_contact
. - You’ll then create the other end of the first relationship. On the
contact
table you’ll create an object relationship betweenassociations_contact_deal.contact_id
andcontact.id
. You can call thiscontact_associations
.
deal
table:
- On the
associations_contact_deal
table you’ll create a object relationship betweenassociations_contact_deal.deal_id
anddeal.id
. You can call thisassociations_deal
. - You’ll then create the other end of the relationship. On the
deal
table you’ll create an object relationship betweenassociations_contact_deal.deal_id
anddeal.id
. You can call thisdeal_associations
.
Views and generated columns
Hasura and Sequin support Postgres views and generated columns. You can use these features to create custom views and columns in your database to simplify querying patterns in GraphQL. For instance, you can create a view calleddeals_and_contacts
that joins your HubSpot deal
table to your contact
table via the associations_contact_deal
join table. The view can contain just the columns you need:
public.users
table with your salesforce.contact
table on the users.id
and contact.user_id
columns. However, the users.id
column is type int4
and the contact.user_id
column is type varchar
. You can create a generated column on the contact
table that casts the user_id
column to int4
in a new column called _user_id
:
users
table and the contact
table using the _user_id
column.