Graphene-django: DjangoConnectionField should have non-null edge and node types

Created on 13 Mar 2020  路  4Comments  路  Source: graphql-python/graphene-django

There's been a bit of discussion around this in #566 and #560 , but I really think this should get another look.

Currently DjangoConnectionField's edges property is required, but the types inside are not:

edges: [EdgeType]!

Given how DjangoConnectionField works, it's not really possible for EdgeType to be optional. It should look like this:

edges: [EdgeType!]!

And then if you look at the EdgeType itself, node is optional:

node: NodeType

But that also is never going to happen. It should be required:

node: NodeType!

Before I start digging and open a PR, are these assumptions correct? Or am I missing something?

鉁╡nhancement

Most helpful comment

Same problem here! IMO at least we should have an option to make edges and nodes to be required.

All 4 comments

@jarcoal I think you're right in your assumptions however the underlying ConnectionField class is defined in Graphene (https://github.com/graphql-python/graphene/blob/master/graphene/relay/connection.py) and the Relay GraphQL spec doesn't define the edges to be required: https://relay.dev/graphql/connections.htm

I think it makes sense for the DjangoConnectionField to have required edges (because of it's implementation) but it might be a bit tricky to implement. If you can create a PR for it that would be great though! Let me know if you need any help.

I'm also having problems here. With a DjangoConnectionField it is at least possible to work round this by creating your own NonNullConnection class, but I can't find such a solution for DjangoFilterConnectionField.

Same problem here! IMO at least we should have an option to make edges and nodes to be required.

same problem here!

@jarcoal I also think that you are right

Was this page helpful?
0 / 5 - 0 ratings

Related issues

timothyjlaurent picture timothyjlaurent  路  3Comments

dan-klasson picture dan-klasson  路  4Comments

flame0 picture flame0  路  4Comments

hyusetiawan picture hyusetiawan  路  4Comments

nickhudkins picture nickhudkins  路  3Comments