Open arjunyel opened 5 months ago
Non null database columns on any table should show up as non null graphql types.
Does the join table have not null constraints applied to the join columns?
Yes the columns are non null
Thanks for the report. I'm relabeling this item because the cli is the component responsible for generating opendd spec for the engine from the ndc-spec schema response that ndc-postgres returns. In that schema response ndc-postgres only reports foreign keys, and is not responsible for the nullability of a relationship model in graphql types.
I understand the issue now, the relationships themselves should be non nullable, not the fields. We will get back to you. (editing this message to reflect my updated understanding)
@arjunyel had a word with the team
For a general relationship, although the key may be present on the source table, it is not guaranteed that the corresponding row is present on the target table. That is why, for a general relationship, the graphql relationship is nullable.
However, if the database makes additional guarantees (like non nullable foreign keys constraints), we could potentially make the relationship non nullable as well. This is a feature we can look into adding to the engine metadata.
@nullxone this makes working with relationships in client code really difficult, I am having to override auto generated typescript types manually
Component
c/v3-ndc-postgres
What is the current behaviour?
The objects linked to a many-to-many table are nullable
What is the expected behaviour?
The linked models should be non-null.
How to reproduce the issue?
Screenshots or Screencast
Should be User! and Tag!
Please provide any traces or logs that could help here.
Any possible solutions/workarounds you're aware of?
Keywords
many-to-many table non-null