apollographql / apollographql/apollo-server
set depth in nested graphql quries
- Dominant language
- TypeScript
- Stars
- 14k
- Forks
- 2k
- Avg merge
- 5h 30m
- Merged PRs (30d)
- 1
Description
### Issue Description
# How i can prevent is drilling?
Implementing Federated GraphQL using Apollo Federation:
i have this query:
```
query Query {
reviews {
user {
reviews {
user {
reviews {
user {
reviews {
user {
reviews {
user {
.....
}
}
}
}
}
}
}
}
}
}
}
```
This query is attempting to fetch reviews and the associated user information recursively. However, it leads to excessive nesting, making the query less efficient and potentially causing performance issues.
and this is review schema =
```
gql`
type Review {
id: ID
rating: Float
content: String
productId: ID
userId: ID
user: User
}
extend type User @key(fields: "id"){
id: ID @external
reviews: [Review]
}
extend type Product @key(fields: "id"){
id: ID @external
reviews: [Review]
}
type Query @extends {
reviews: [Review]!
review(id: ID!): Review!
}
`
```
and user schema:
```
gql`
type User @key(fields: "id") {
id: ID!
email: String
username: String
}
extend type Query {
users: [User]!
user(id: ID!): User!
}
`
```
### Link to Reproduction
---
### Reproduction Steps
_No response_
Contributor guide
Research direction
Start with the nested query and the Review, User, and Product schema definitions included in the issue. Clarify the desired maximum nesting depth and expected behavior for deeper queries, then create a minimal reproduction before assessing the implementation scope.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100