Skip to content

Node & edges connection types are nullable #185

Closed
@Wenzil

Description

@Wenzil

Currently, typings indicate that the node type of a connection must be nullable. It would be nice if it could be made non-nullable:

const MyConnection = connectionDefinitions({
    nodeType: new GraphQLNonNull(MyNodeType)
});

On the other hand, I feel like the edges field of a connection should always be a non-nullable list. E.g. it should have the type [SomeEdgeType]! rather than [SomeEdgeType]. My reasoning is that a connection with no edges should represent this with an empty list, and not a null value.

Similarly, each edge should be non-nullable. E.g. it should have the type SomeEdgeType! rather than SomeEdgeType.

In short, current connection types look like this:

type MyConnection {
  edges: [{
    node: NodeType
  }]
  pageInfo: { ... }!
}

and it could be improved to:

type MyConnection {
  edges: [{
    node: NodeType! // Nullability is parametrizable
  }!]!
  pageInfo: { ... }!
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions