'Strapi v4 too much nested data
I'm rewriting strapi v3 queries to v4 (GraphQL), and with new fields 'data' and 'attributes', I have a problem going too much deep into nested objects, an example of how data looks:
user {
data {
id
attributes {
company {
data {
id
attributes {
location {
data {
id
...
}
}
}
}
}
}
Am I missing something in the documentation, is there a way to avoid this much nesting, should I restructure data in Model, or?
Solution 1:[1]
This is a known pain point for many, but no immediate official solution in sight. Gotta deal with it.
Solution 2:[2]
My friend, that's the way now:
user.data.attributes.company.data.attributes.location.data
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | T1000 |
| Solution 2 | Tyler2P |
