graphql / graphql/graphql-spec

Feature exploration/request: nested data (nth-degree recursion)

Open
#237 29 comments 15 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
14.6k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Two prior conversations triggered this ticket. This (closed) ticket #91 and this conversation in Slack https://graphql.slack.com/archives/general/p1478088194004298. Unlike the closed ticket, this should explicitly be considered a feature exploration/request, not necessarily a question about how to do nesting/recursion.

Understanding that GraphQL is about being explicit and declarative, how would/could one be declarative *and* specify recursion. This is a known limitation that would need to be addressed: https://facebook.github.io/graphql/#sec-Fragment-spreads-must-not-form-cycles One suggestion from the Slack thread was to relax the requirement a bit by allowing `@recursive` limits. There may need to be a default limit too.

Potential example.

```
fragment PersonFields on Person {
name
primaryAddress { street }
parents @recursive(maxDepth: 8)
}
fragment EmployeeFields on EmployeeInterface {
primaryAddress { street}
boss @recursive(maxDepth: 4)
}

{
person(id: 1) {
… PersonFields
… EmployeeFields
}
}
```

One strong aspect of graphs is deep nesting. Is this a possibly worthy feature request?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.