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

Generated GraphQL edges and nodes should be non nullable #3998

Open
1 task done
shadiramadan opened this issue Apr 2, 2024 · 0 comments
Open
1 task done

Generated GraphQL edges and nodes should be non nullable #3998

shadiramadan opened this issue Apr 2, 2024 · 0 comments

Comments

@shadiramadan
Copy link

In the GraphQL schema, edges and nodes should be made non nullable.

If there are no edges it should be an empty array.
A node should simply not be in the array if it is null so that should also be non-nullable.

  • I have searched the issues of this repository and believe that this is not a duplicate.

Summary 💡

Similar to graphql/graphql-relay-js#185

Motivation 🔦

When using codegen on the generated graphql schema (e.g. in Typescript). It becomes frustrating to add tons of boilerplate just to handle nodes or edges not existing in results.

As an example:

return (data.organizations.edges ?? []).map((org) => ({
    organization: org?.node,
    workspaces: (org?.node?.workspaces.edges ?? []).map(
      (workspace) => workspace?.node
    ),
  }));

vs.

return data.organizations.edges.map(({node: org}) => ({
  organization: org,
  workspaces: org.workspaces.edges.map(
    ({node: workspace}) => workspace
  ),
}));
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

No branches or pull requests

1 participant