Strapi v4 too much nested data

Viewed 774

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?

2 Answers

My friend, that's the way now:

user.data.attributes.company.data.attributes.location.data 
Related