hasura / hasura/graphql-engine

Column Presets for Inserting through Relationships (e.g., for polymorphism)

Open
#9,629 0 comments 0 reactions 0 assignees View on GitHub
k/enhancement t/native-dbs
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Is your proposal related to a problem?

This idea arose in the context of polymorphic entities. Imagine a polymorphic entity `phone_numbers`, which has object relationships with `persons` and `organisations` through a column `polymorphic_id`. There is another field called `polymorphic_type` which is an enum of the values "persons" and "organisations".

### Describe the solution you'd like

Expand the column presets feature so it can be used in object and array relationships. This would probably need to be keyed by role/all roles. e.g., on the person object relationship for phonenumber, some additional field like `set: {[role]: {[key: string]: string}}`

### Describe alternatives you've considered

At the moment we set `polymorphic_type` from the frontend. This feature request would remove the need for the front-end to do that, so it's not like we're stuck. It would just be cool.

Thanks for your consideration!

Contributor guide

Open the contributing guide

Research direction

No source files or tests are named. Start by locating the column presets implementation and the handling for inserts through object and array relationships, then trace how relationship roles are represented. Done means presets can set relationship-specific values, including the polymorphic_type value, without frontend code setting it separately.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql
Domain
api, database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.