shopifyCustomer.tags temporarily not in Array form
shopifyCustomer.tags
normally comes through as an Array, but I’ve noticed that sometimes it first appears as an empty string or just a string, and then later gets converted into an Array.
When using tags in JavaScript, I handled this by checking if it’s an Array, and if it’s an empty string I replace it with[]
, and if it’s a string I wrap it in an Array. That way, no errors occur.
My question is: when using filters in Gadget (e.g. with findMany), will filtering still work correctly even if the value hasn’t yet been converted into Array form at runtime?7 Replies


That's a good question. I think that a string is still valid JSON so I would assume that the it should still be searchable with the same filters. Let me test to confirm it for you
So it looks like the filters wont be able to match a string json value
You may have to modify the value that comes in and transform it into an array before saving the record (if not an array)
Thanks! To confirm my understanding and next steps:
In the default Gadget actions api/models/shopifyCustomer/actions/create.js and api/models/shopifyCustomer/actions/update.js, the code calls:
applyParams(params, record);
await save(record);
If we insert a step between those two lines to normalize tags—i.e., “if not an Array, convert "" → [] and "foo" → ["foo"]—then the filters should work as expected. Is this what you mean by transforming the value before saving?
Also, based on my observation that tags eventually becomes an Array later on, it seems Gadget converts it internally at some point.
Are there any plans to move that conversion earlier in the pipeline so that findMany/filters see tags as an Array immediately? (if this behavior is unexpected on your side)What I mean is set
record.tags
prior to the save function callGot it, so as long as I normalize record.tags before calling save(record), it should be fine?
Yes, exactly
I'm going to mark this as closed since it has been resolved
Do you like this answer?