I recently work with Commercetools platform and I have such a question. How we can find product or category and so on by incomplete name?
For example if in my url I wrote something like this
https://localhost:8080/cat?catName=G
I wanna find all categories which contains a G
. How we can done this?
You can get this with a categoryAutoComplete query on the GraphQL API. The following query asks for categories beginning with "hi". You need to provide two characters at least, with one letter only it doesn't return any result.
{
categoryAutocomplete(locale: "en", text: "hi") {
results {
name(locale: "en")
}
}
}
On my test project it this query returns two categories that have the term "hint" in their English name:
{
"data": {
"categoryAutocomplete": {
"results": [
{
"name": "Test duplicate order hint"
},
{
"name": "order hint test"
}
]
}
}
}
Is this helpful?