-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
Working with deeply nested schemas, it can become very cumbersome to expand every referenced entry in the queries. For example:
groq`*[_type == "movie" && _id == "123"]{
...,
"directors": directors[]->{
...,
"awards": awards[]->{
...,
"organization": organization->{
...,
"country": country->
}
},
"filmography": filmography[]->{
...,
"cast": cast[]->{
...,
"agency": agency->
}
}
},
"producers": producers[]->{
...,
"awards": awards[]->{
...,
"organization": organization->{
...,
"country": country->
}
},
"projects": projects[]->{
...,
"budgetDetails": budgetDetails->{
...,
"currency": currency->
}
}
}
}
`;
Not sure which syntax would make the most sense, but something simple like this would work wonders:
groq`*[_type == "movie" && _id == "123"]{
(...)->,
}
`;
As in, expand every reference field and also those within the references themselves, recursively. Parameters that could be helpful:
- A way of limiting the maximum depth to expand (example max depth 3, any references deeper than 3 levels wouldn't get expanded)
- A way of limiting expanding circular dependencies. Maybe a boolean, that if true, when a reference was already expanded somewhere else in the current tree branch, it wouldn't get expanded again (if you have some sort of circular dependency like
person1->twinfield (also type person) valueperson2-> againtwinfield inperson2->person1,person1wouldn't be expanded since it was already expanded at the root)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels