You can do it with the search, there is a little caveats with searching on an GUID, you need to use a lowercase GUID without brackets and dashes.
Example:
{
search(
fieldsEqual:[{name:"Products",value:"8826e32b70ac42aa923aff0a3a313f34"}]
rootItem:"/sitecore/content/MyApp/Categories"
) {
results {
items {
item {
id
name
path
}
}
totalCount
}
}
}
Or a sample query with also the Products include. In This Example the value 8826e32b70ac42aa923aff0a3a313f34 is the GUID of your product and should be in this lowercase format.
{
search(
fieldsEqual:[{name:"Products",value:"8826e32b70ac42aa923aff0a3a313f34"}]
rootItem:"/sitecore/content/Categories"
) {
results {
items {
item {
id
name
path
products: field(name : "Products") {
value
...Products
}
}
}
totalCount
}
}
}
fragment Products on MultilistField {
tags:targetItems {
name
id
}
}
Also you can get the data without the search but currently not sure how to filter this, but with the following query you get al the data you need, but it contains all Categories, so to much data, but you can filter it later (outside GraphQL). at least a good starting point.
query MyDemoQuery( $contextItem: String!)
{
contextItem: item(path: $contextItem) {
id
}
categories: item(path:"/sitecore/content/MyApp/Categories") {
id
children{
id
products:field(name : "Products") {
...Products
}
}
}
}
fragment Products on MultilistField {
tags: targetItems {
id
name
}
}