Add the Cargo Table to Hasura
In the Hasura Console click the Data tab and click
Create Table
under the default database.Table name is
cargo
Click
Frequently used columns
and select the id one with UUIDAdd four other columns
- launch_id - text
- name - text
- user_id - text
- weight - integer
Add the table. You should now be on the modify page of the table.
Under configure fields for both launch_id and user_id we need to edit the GraphQL Field Name option to the JavaScript naming convention of camelCase instead of the Postgres naming convention of underscores.
- launch_id -> launchId
- user_id -> userId
Click on the permissions table and enter a new role of
user
Keep the insert permissions as disabled, we want to do our own validation on our server before inserting
For select permissions we allow with custom check of user_id _eq
X-Hasura-User-Id
, allow user to access all columns, and allow them to make aggregation queries.For update permissions the pre-update check will be the same as
select
and allow them only to update thename
column.Finally, for delete allow with the same custom check as
select
For homework, send an email via Sendgrid whenever a new cargo is added using Hasura's Data Hub
- Build apps and APIs 10x faster
- Built-in authorization and caching
- 8x more performant than hand-rolled APIs