hasura / hasura/graphql-engine
Multi-columns enum configuration
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
### Is your proposal related to a problem?
It is quite common that an enum table could have multiple columns. For example, you could have two enum tables: `colors`, `color_types` and then in the `colors` table you could have the `type` column and its associated `color_types`
Right now, if you make `colors` an `enum` table, the `type` column will become a comment.
When in fact it would be great to be able to create multi-column enums like this example:
`colors` table (rows data sample):
```
[
{ color: "Red", type: "Primary" },
{ color: "Orange", type: "Secondary" },
{ color: "Red-Orange", type: "Tertiary" }
]
```
`colors` enum:
```
{
"Red": "Red",
"Orange": "Orange",
"Red-Orange": "Red-Orange",
}
```
`color_types` enum:
```
{
"Primary": "Primary",
"Secondary": "Secondary",
"Tertiary": "Tertiary",
}
```
`colors_associated_types` enum:
```
{
"Red": "Primary",
"Orange": "Secondary",
"Red-Orange": "Tertiary",
}
```
### Describe the solution you'd like
In the console, instead of having a simple `enum` toggle, it would be great to be able to configure enums, with the following information:
- Enum name
- Enum key column (needs to be unique)
- Enum value column (can be the same as key by default, or can be another column that it not unique)
- The enum order (sometimes you could have columns with weights to determine the order)
### Describe alternatives you've considered
Right now you have two solutions:
- Query Hasura for these enum tables and generate the relation using application code (probably the most common solution)
- Build a custom static code generator that will generate these enums by doing Hasura table queries - I don't think any generator can support this out of the box, so this is a lot of potential extra work that probably most people aren't doing
Contributor guide
Research direction
Start by reviewing the console's enum-table configuration and the existing generated enum behavior. Trace how the enum key, value, and ordering are currently selected, then assess the requested multi-column configuration against the colors and color_types examples. Done means the console can configure these fields and generate the associated enums consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, postgresql, typescript
- Domain
- api, databases, frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100