- Strapi Version: 4.13.7
- Operating System: mac
- Database: mysql
- Node Version: 20.5.0
I am working with strapi for some months and working with a project using Graphql. Let’s get into my scenario:
I have Property Collection for listed properties and User Collection for authenticated users. I have my task to favorite the property and reflect it on my Property List page in UI.
So I created new collection Favorite with User and Property (both having relation: Favorite has one User/Property). I could successfully create the Favorite with User and Property populated when I favorited a property which is published as well.
Now in the properties list page, I want to display the properties with favorite icon ON or OFF according to the data I have in the Favorite collection.
For that I added favorites field on Property collection with relation (Property has many Favorites) and finally I am fetching the properties with following graphql query but I am getting null favorites though I have favorite data related to property.
But when I manually add favorites in Propetry from strapi admin, the data is populated in the query.
I wish that the relation to be established automatically. Am I wrong in my approach or missing something. Please suggest!!