System Information
- Strapi Version: v4.1.5
- Operating System: Ubuntu 20.04.4 LTS
- Database: PostgreSQL
- Node Version: v14.19.1
- NPM Version: 6.14.16
Hello all,
I have problems geting a relation in a component in a dynamic zone. The example data:
{"data":{"id":1,"attributes":{"createdAt":"2022-05-06T06:21:11.533Z","updatedAt":"2022-05-06T06:21:47.905Z","publishedAt":"2022-05-06T06:21:12.282Z","fruits":[{"id":1,"__component":"fruits.apple","title":"juicy one","tree":{"data":{"id":1,"attributes":{"location":"somewhere","createdAt":"2022-05-06T06:19:21.860Z","updatedAt":"2022-05-06T06:19:33.111Z","publishedAt":"2022-05-06T06:19:33.109Z"}}}},{"id":1,"__component":"fruits.pear","title":"also very juicy","tree":{"data":{"id":2,"attributes":{"location":"over","createdAt":"2022-05-06T06:19:27.279Z","updatedAt":"2022-05-06T06:19:29.790Z","publishedAt":"2022-05-06T06:19:29.787Z"}}}},{"id":2,"__component":"fruits.apple","title":"another apple","tree":{"data":{"id":3,"attributes":{"location":"the rainbow","createdAt":"2022-05-06T06:19:39.767Z","updatedAt":"2022-05-06T06:19:40.333Z","publishedAt":"2022-05-06T06:19:40.332Z"}}}}]}},"meta":{}}
I got this data with the following query:
api/buckets/1?populate=fruits.tree
So there are buckets which have a dynamic zone. Inside the dynamic zone there are fruits. Fruits have a relation to a tree. Now I want to get a fruit of a specific type out of the bucket filtered by ID and the fruit’s relation. The closest I got was this:
api/buckets/1?populate[fruits][filters][id][$eq]=1&populate[fruits][populate][0]=tree
And it returned:
{"data":{"id":1,"attributes":{"createdAt":"2022-05-06T06:21:11.533Z","updatedAt":"2022-05-06T06:21:47.905Z","publishedAt":"2022-05-06T06:21:12.282Z","fruits":[{"id":1,"__component":"fruits.apple","title":"juicy one","tree":{"data":{"id":1,"attributes":{"location":"somewhere","createdAt":"2022-05-06T06:19:21.860Z","updatedAt":"2022-05-06T06:19:33.111Z","publishedAt":"2022-05-06T06:19:33.109Z"}}}},{"id":1,"__component":"fruits.pear","title":"also very juicy","tree":{"data":{"id":2,"attributes":{"location":"over","createdAt":"2022-05-06T06:19:27.279Z","updatedAt":"2022-05-06T06:19:29.790Z","publishedAt":"2022-05-06T06:19:29.787Z"}}}}]}},"meta":{}}
But now I only want the apple with ID 1 without the pear which has the same ID and I don’t know how to query that. I tried this query but it didn’t make a difference:
/api/buckets/1?populate[fruits][filters][id][$eq]=1&filters[fruits][__component][$eq]=fruits.apple&populate[fruits][populate][0]=tree
Does anyone has an idea?