Filtering items that is linked to tree-like model

I’ve following models

  1. Category
  2. Item

1st model is having a structure similar to parent-child, like Category & Subcategory.
Item is linked to Category/Subcategory.

I’m trying to filter all items that are linked to either Category or Subcategory.

For example:

Item 1 is linked to Cat1
Item 2 is linked to Subcat11 (Subcat11 is the child of Cat1)

I want both the items when I do pass Category as Cat1. Can anyone please help?
Thanks in advance

hi @anshumansworld , welcome :slight_smile:

I suppose Category is using a tree like structure:

And I suppose you are trying to filter records with GraphQL.

Am I right?

At the moment you cannot filter a record by a link field moving up its hierarchy. I think you should do two queries. One where you find all subcategories ids for a particular category and then another query where you filter Items based on Category id and all of its subcategories ids. You can use the anyIn graphql filter to do that.

Hope this helps :slight_smile: