graphql-python / graphql-python/graphql-relay-py

Why are nodes optional?

Open
#19 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
144
Forks
41
PR merge metrics
No merged PRs in 30d

Description

I was trying to dig through this to figure it out, and I apologize if there's a good reason for this.

It seems to me that a paginated connection (e.g. `DjangoConnectionField` or `DjangoFilterConnectionField`) always has edges and nodes. What's the use case for these being nullable?

The reason I bring this up is because, when using TypeScript with the generated schema, it results in lengthy checks like this:

```tsx
{edges.map(edge => (


{edge &&
edge.node &&
edge.node.id (
...
```

As far as I can tell this is set up here:
https://github.com/graphql-python/graphql-relay-py/blob/master/graphql_relay/connection/connection.py#L44

Could there be `required` on edges/nodes? At least as an option it'd be a breaking change. Right now I'm not sure how to override this.

Contributor guide

No contributing guide indexed for this repository

Research direction

Read graphql_relay/connection/connection.py around line 44 to confirm how edges and nodes are declared. Investigate whether nullability can be configured without breaking existing schemas; done means an explicit option exists and the generated schema reflects the selected nullability.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, python
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.