1

I am trying to run this query in react app , I am using using apollo client, It run successfully but does give me expected result. My Query

{
  productProjectionSearch(filters: {string: "categories.id:\"011d3888-27be-4d11-bf1e-4e3ccb737c8b\""}, fuzzy: true) {
    count
    results {
      categories {
        id
      }
      version
      published
      name(locale: "en")
    }
  }
}

My react apollo client query

query {
    productProjectionSearch(
      filters: {
        string: categories.id:${'011d3888-27be-4d11-bf1e-4e3ccb737c8b'}"
      }
      fuzzy: true
    ) {
      count
      results {
        categories {
          id
        }
        version
        published
        name(locale: "en")
      }
    }
  }

it does not give me expected result , it's not considering the id which I input i.e. string: categories.id:${'011d3888-27be-4d11-bf1e-4e3ccb737c8b'}"

dan kia
  • 11
  • 2
  • if its giving expected result, what is the question? – Sajeetharan Feb 01 '22 at 04:54
  • it does not give me expected result , it's not considering the id which I input i.e. string: categories.id:${'011d3888-27be-4d11-bf1e-4e3ccb737c8b'}" – dan kia Feb 01 '22 at 04:58
  • Your filter string misses the double quote at the beginning and I don't know if the apollo client will embed the string template in escaped double quotes. Please see also https://docs.commercetools.com/api/projects/products-search#filters as the filter string has to be correctly formatted – jenschude Feb 01 '22 at 07:39
  • I tried like that as well but still no luck e.g. query { productProjectionSearch( filters: { string: "categories.id:${'011d3888-27be-4d11-bf1e-4e3ccb737c8b'}" } fuzzy: true ) { count results { categories { id } version published name(locale: "en") } } } – dan kia Feb 01 '22 at 10:20
  • It must be exactly like you wrote it in the first code block: {string: "categories.id:\"011d3888-27be-4d11-bf1e-4e3ccb737c8b\""} – jenschude Feb 02 '22 at 07:25
  • No it does not work with that either , It gives this error GraphQLError: Syntax Error: Invalid number, unexpected digit after 0: "1". – dan kia Feb 02 '22 at 11:09

0 Answers0