Define input enums in WHERE HAS conditions #2722
Closed
DrPowerSlam
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Created as issue instead, sorry for the discussion noise: #2723
When defining a WHERE HAS query with a condition in complex queries, Lighthouse will fetch the column enums from the parent type, not the relation, if the
wheredefinition uses any sort of column enumeration.{ drivers( where: { OR: [ {HAS: {relation: "employee", condition: {column: NAME, value: "Peter"}}}, // `column: DriverColumnEnum` instead of `column: EmployeeColumnEnum` {column: ID, operator: EQ, value: "6217"} // `column: DriverColumnEnum` ] } ) { data { id name employee { name } } } }I think it would make sense if you could define the relations in a where, the same way we do in
orderBy:This would both enable stronger schema generation by having enums for the relation name (right now it's currently just a string), make
orderByandwheremore similar in how they are written in the schema definitions, and of course fix the issue described in the discussion link below.One of the huge benefits of using enum types in the schema, is that the schema documentation can explain exactly what a API consumer can use, so I think this would be the absolute best solution for usability. Otherwise a API consumer will need intricate knowledge of the database columns available.
I think it would also make sense that the
relations.columntype will default toStringif column enumerations are missing, instead of trying to resovle the column enum type of the parent.Thanks for taking your time to consider this. :)
Original Q&A discussion this is based on: #2720 (comment)
Beta Was this translation helpful? Give feedback.
All reactions