How can I localize the input query depending on market?

newbie_01
Shopify Partner
32 0 7

My function needs different variant metafields depending on the market selected.  According to the specs the query can't grab multiple metafields in a namespace, because the key is required.

(In a regular query, you can ask for the first x metafields inside a namespace, without specifying keys)

If I have different metafields named namespace.{market_handle} can I customize the input query so only the right metafield is pulled?

Since each shop may have different markets setup, the keys can't be hardcoded.

The only other way I can think of is to save data for all markets into a single metafield (as a json blob), and have my function sort through it, pull the right data based on the current market and discard the rest.

Any ideas would be appreciated.

Replies 0 (0)