sikanhe / gqtx

Code-first Typescript GraphQL Server without codegen or metaprogramming
458 stars 13 forks source link

feat: PageInfo is nullable #62

Closed maraisr closed 2 years ago

maraisr commented 2 years ago

PageInfo is a nullable entity, making all members NonNull please see https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo.Fields

sikanhe commented 2 years ago

@n1ru4l You are familiar with Relay, can you help take a look?

sikanhe commented 2 years ago

I remmeber this - I ported the behavior from graphql-js https://github.com/graphql/graphql-relay-js/issues/243

The reason cursors are nullable is because it's unclear what they should be when array is empty. But if array is empty, we can still get information about whether there is next page. So I am not sure that returning null for PageInfo is correct when array.length === 0

maraisr commented 2 years ago

The spec clearly says the cursors must be non-null, see link I attached in pr description.

The field is aptly named "PageInfo" alluding to the fact it's information about a page, if there is no page — aka edges is empty — then the field (PageInfo) is null.

There is chatter about the repo you linked "graphql-relay-js" so still waiting on an official answer.

For now, maybe our best bet is to check what our c# friends are doing with HotChocolate.

sikanhe commented 2 years ago

Closing this as all other relay implementations do the same

maraisr commented 2 years ago

Just because they all do the same, doesn't make it right.