Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

entgql: make connection node non-null #597

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yukukotani
Copy link

@yukukotani yukukotani commented Jul 20, 2024

ent/ent#3998

What's changed

Generates node field in connection edge types as non-null types instead of nullable types.

Background

According to the spec, node field can be non-null.

An “Edge Type” must contain a field called node. This field must return either a Scalar, Enum, Object, Interface, Union, or a Non-Null wrapper around one of those types. Notably, this field cannot return a list.
https://relay.dev/graphql/connections.htm#sel-FAHFFDCAACEP0xF

On the other hand, edges field in connection types are defined as just a list type that wraps an edge type, which means [Edge] but not [Edge]!.

A “Connection Type” must contain a field called edges. This field must return a list type that wraps an edge type, where the requirements of an edge type are defined in the “Edge Types” section below.
https://relay.dev/graphql/connections.htm#sel-FAFFFDCAACCzEsY

So this PR only changes node field and keeps edges field as it is.

Concerns

My concern is whether we should consider this a breaking change.

GraphQL API clients can accept the transition from nullable to non-null fields without any change or breaking. How about servers? I'm not sure this change would break server implementations using ent.

If so, we can introduce this change as an option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant