hasura / hasura/graphql-engine

View of table column with enum is not an enum in the API

Open
#9,436 3 comments 4 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?

Say I have a table which contains a text column with a foreign key to a Hasura enum table.

In the GraphQL API, Hasura strongly types the column with a GraphQL enum type.

Now, I create a view of that table with the same column type. The GraphQL API now unfortunately loosely types the column as `String`.

### Describe the solution you'd like

The type of the column in the GraphQL API of the view should reflect the type of the column in the underlying data. I understand the difficulty in doing this given Hasura's current design for enums -- but nevertheless, this is a significant problem with using views with Hasura and should be solved.

### Describe alternatives you've considered

There aren't any reasonable ones as far as I can tell.

Contributor guide

Open the contributing guide

Research direction

Reproduce the reported schema with a table containing a Hasura enum-backed text column and a view exposing the same column. Start by examining how Hasura generates GraphQL types for the table and view; done means the view column is exposed with the same GraphQL enum type rather than String.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, postgres
Domain
api, database
Issue type
Bug
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.