Closed intellix closed 1 year ago
Would you hate me for changing that to this? Can't think of anything better/easier right now:
function nodeType(connectionType) {
return connectionType._fields.edges.type.ofType._fields?.node.type ??
connectionType._fields.edges.type.ofType.ofType._fields?.node.type ??
connectionType._fields.edges.type.ofType.ofType.ofType._fields?.node.type;
}
Then it supports all three levels:
edges: [UserEdge]
edges: [UserEdge!]
edges: [UserEdge!]!
@intellix Might want to verify that the ofType
parent is a list or nonNull, but otherwise sounds good to me.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Was just trying to debug why I couldn't set my edges to be notNull (so I can make a strictNulls project less defensive from generated types).
After breakpointing through the code, I noticed it was this function: https://github.com/mickhansen/graphql-sequelize/blob/578478e9d75e1a65b439b491a9eba8c0acf16b23/src/relay.js#L119-L121
I believe when you go from:
To:
It's essentially wrapping the types in GraphQLNonNull so you have to go deeper:
So I guess it needs to search down the types better in case of non-nulls