https://github.com/kevinmichaelchen/genqlient-custom-type-omitempty-bug
Bug with custom Genqlient type and Hasura relationship
https://github.com/kevinmichaelchen/genqlient-custom-type-omitempty-bug
Last synced: 3 months ago
JSON representation
Bug with custom Genqlient type and Hasura relationship
- Host: GitHub
- URL: https://github.com/kevinmichaelchen/genqlient-custom-type-omitempty-bug
- Owner: kevinmichaelchen
- Created: 2023-04-19T12:42:35.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-19T16:41:46.000Z (about 2 years ago)
- Last Synced: 2025-02-23T22:43:39.416Z (3 months ago)
- Language: Go
- Homepage:
- Size: 34.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bug reproduction
Using custom marshallers on an insert input results in a new
["premarshal" function](https://github.com/Khan/genqlient/blob/v0.5.0/generate/marshal.go.tmpl#L31-L39)
that ignores JSON fields like `omitempty`.This results in a bug where writers to a table also need write permissions on
any
[related](https://hasura.io/docs/latest/schema/postgres/table-relationships/index/)
tables.## The Tables
We have two tables: `person` and `address`.
The `person` table has a relationship to the `address` table.
### The Roles
- The `person-writer` role has full permissions on the `person` table.
- The `address-reader` role has read permissions on the `address` table.
- The application uses both roles via an Inherited Role.## The Bug
This is, at its core, a permissions bug.
Imagine a Postgres database where tables have
[relationships](https://hasura.io/docs/latest/schema/postgres/table-relationships/index/)
to each other, but each table requires different permissions.In order to use an "insert input" for one table, you'll need write permissions
for both tables, even if you only intend on inserting into one table and not the
other.