The parsed query tree.
A Wix filter node suitable for GraphQLQueryVariables.filters.
translateAstToWixFilter({ type: "or",
left: { type: "term", value: "Sodium", phrase: false },
right: { type: "term", value: "Potassium", phrase: false } });
// { or: [
// { term: { field: "name", op: "CONTAINS", values: ["*Sodium*"] } },
// { term: { field: "name", op: "CONTAINS", values: ["*Potassium*"] } },
// ] }
export function translateAstToWixFilter(ast: SearchAst): WixFilterNode {
return translateAstToContainsFilter(ast, (value) => `*${value}*`);
}
Translates a SearchAst into a Wix catalog filter tree.
Leaf terms become a
CONTAINSmatch on the productnamefield (wrapped in*…*wildcards, mirroring the single-term default inSupplierBaseWix). Boolean nodes map to Wix'sand/or/notcombinators, which the catalogproductsWithMetaData(filters: …)endpoint accepts. Thin wrapper over the shared translateAstToContainsFilter (its output is structurally aWixFilterNode).