Why are edges and nodes in relay connection nullable? #3044
Unanswered
bennetpeters
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Using the "entgql.RelayConnection()" annotation generates following types:
Is there a reason that the field "edges" and "node" are "nullable"?
I use a code generator (https://www.the-guild.dev/graphql/codegen) to generate typescript types from a schema and it generates the connection endpoint with null types, which looks a bit dirty to me.
query:
query in frontend:
resulting typescript types:
to get the nodes there are several null checks necessary:
const nodes = data?.dataFields.edges?.map(x => x?.node) ?? [];
One workaround for me would be defining my own connection:
I hope you can understand my "problem" here, maybe I'm missing something, but it doesn't feel 100% correct having to null check the edges and nodes.
Thanks in advance for the reply/help!
Beta Was this translation helpful? Give feedback.
All reactions