Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strapi v4 too much nested data

Tags:

graphql

strapi

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?

like image 419
Marko B. Avatar asked Jul 01 '26 13:07

Marko B.


1 Answers

This is a known pain point for many, but no immediate official solution in sight. Gotta deal with it.

https://forum.strapi.io/t/discussion-regarding-the-complex-response-structure-for-rest-graphql-developer-experience/13400/35

like image 93
T1000 Avatar answered Jul 05 '26 08:07

T1000



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!