Suppose I have some entries in a section called 'product' that are related to a category call 'brand' - I know I can get the brands that are related to each product that match a search term using GraphQL like so:
query Query($searchTerm: String) {
entries(search: $searchTerm, section: "product") {
... on product_product_Entry {
brand {
id
}
}
}
}
Which returns something like this:
{
"data": {
"entries": [
{
"brand": [
{
"id": "3"
}
]
},
{
"brand": [
{
"id": "5"
}
]
},
{
"brand": [
{
"id": "3"
}
]
},
...
What I'm looking to do is get all the brands that are related to the products matching the search, but obviously if I use the above query then the response will get very big very quick. Is it possible to get just the distinct brand id values returned from the above GraphQL query? Or am I better off making a module with a controller action and querying the database that way?