-
Notifications
You must be signed in to change notification settings - Fork 183
Query nested object more than 2 depth if they have relations #87
Comments
I came across this issue while experiencing the same issue of deep relations not being included in my queries. After a day of research, I finally found the solution that worked for me, and might work for anyone who has a problem similar to what this issue describes. I have a content type My fix was to customize the
My hypothesis is Strapi controllers don't include deep many to many relations by default in queries. You have to explicitly include them. But then, once you explicitly include a relation, you need to explicitly include all relations you want. Once I modified my |
This solution worked for me. I have content type category with a relation of sections and section has a relation of articles. The articles were not showing in the response as it's relational depth is more than 2
In my category controller:
Hope this helps somebody :) |
Hi Jimsheen, Which versions of Strapi / Gatsby are you using? Can you maybe share your whole Category Controller? Thanks in advance :) |
Hey, this is for Strapi v3.6.8 and Gatsby v3.11.1 Not much else in the controller other than the following:
|
Hi James, Thanks for swift reply. Gotcha, makes sense. V4 works differently. You can address the nested fields it in your gatsby-config. Makes live easier. :) |
@leasytime No worries! I do have a project running v4 but haven't run into nested relation issue like this yet as it's a flat structure. I thought this was a Strapi problem not returning nested data - not Gatsby. Do you have an example of the gatsby-config you mentioned? |
Yes, please see below for a relational depth of 3 : Page > Popular_Products > Image
edit: |
Hi, please forgive my pool English.
I want to use gatsby-source-strapi to query objects with relations in one single graqhql query.
I added 3 contents and set relations in Strapi, but in Gatsby I still cannot query nested objects more than 2 depth like:
I can only query the 'obj_2' in 'obj_1', but 'obj_3' cannot be query. Is there any way to get the nested data more than 3 depth?
The text was updated successfully, but these errors were encountered: