-
Notifications
You must be signed in to change notification settings - Fork 183
Unable to query relation within relation; returns ID only #127
Comments
Hello Sam, |
@samOpenforce I did some tests on this and it seems the fetch call to strapi is not returning the relation object, but rather only the relation id for a relation within a relation. |
Ok, so the issue seems that strapi uses the REST interfaces, which queries only 1 level. As per this issue 4062. Instead of implementing the fix given in the above issue, I am going to try to use the |
Can confirm the |
Hey Jal. Thanks for your input and good luck with your investigations. We will explore alternative solutions to this issue as well. Please let me know what you find? |
@Jaikant The problem of using |
(Please read comment, two comments below - I no longer recommend the below) For anyone else stumbling here, you can use
|
Thank you @Jaikant for this fix! Really helped me out. For eg: query MyQuery {
strapi {
authors {
pic {
url <-- this
imageFile {
childImageSharp {
fluid {
src
}
}
}
}
}
}
} And for anyone using Amazon S3 or Cloudinary, make sure to replace |
@mihirgupta0900 I no longer recommend to use There are many issues with gatsby-source-graphql like -
The above two are the big ones, there are other smaller issues which could be easily fixed like it doesn't download images on its own, needs extra code . In the end it was much easier adding changes to the strapi layer to get the relation data, it is simple. Within your
for e.g. if we wanted to update the author relation within articles
|
Ahh, there goes two days worth of effort down the drain. I did notice some issues that you mentioned in point 2 and the solution you just mentioned sounds simple. I'll try this out by evening! Thanks again. |
I'm also just encountering the challenges of |
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 :) |
Using strapi 3.0.0-beta.20 with graphql.
In Strapi we have created a collection-type that has a relation, which in turn has a relation.
When we query, the first relation is shown completely but the next level only delivers the id of the relation
Has this to do with the maximum depth of the query? If so, can this depth be set in the gatsby-source-strapi config?
As an example
we have these collection types:
"job_post"
"job_page"
where each of the "job_post" has a single relation to a "job_page" and might also have a single relation to an "alternative_job_post". If we query this:
we receive the following results:
as you can see the "Job-posts_5" has a relation to an alternative job_post set, but as a result for the "job_page" we just receive the id. The expectation is that we get the complete content of the "job_page" object and not just the id.
The text was updated successfully, but these errors were encountered: