hasura / hasura/graphql-engine
Enum fields in views unexpectedly treated as strings
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
### Version Information
Server Version: 2.0.3 (OSS)
### What is happening?
Assume `table1 (id bigserial, col1 text)`, with `col1` having foreign key to an enum table (-> `some_enum`).
Also, let there be a view `view1 AS SELECT id, col1 FROM table1`.
Finally, the permissions (for some role) of table1 shall not allow selecting `col1`, only the permissions of `view1` do. (E.g. insert permissions on `table1` + defaults might also be needed).
Now, export the graphql schema for that role/permissions.
When compared to the schema when `table1.col1` is instead selectable, we see that only the latter one includes the `enum { ...values...}` in the schema.
More specifically, `input table1_bool_exp` would contain `col1: some_enum_comparison_exp`, but `input view1` instead `col1: String_comparison_exp`, with `input some_enum_comparison_exp` and consequently `enum some_enum` completely missing.
### Expected behavior
`input view1` utilizes `col1: some_enum_comparison_exp`.
Contributor guide
Research direction
No file or test is named. Start by reproducing the schema export for the role using table1.col1 directly versus through view1, then trace schema generation for the view's column type. Done means view1.col1 uses some_enum_comparison_exp and the some_enum values are present in the exported schema.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, postgres
- Domain
- api, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100