plugin-graphql icon indicating copy to clipboard operation
plugin-graphql copied to clipboard

Filter with String Array

Open MLDMoritz opened this issue 6 years ago • 0 comments

If you try to filter for array items it handles the parameter as an Object, which it isn't.

Example: CarModel.dispatch('fetch', { filter: { carMake_slug_list: 'audi' }}) works fine while CarModel.dispatch('fetch', { filter: { carMake_slug_list: ['audi', 'bmw'] }}) doesn't.

I got it working with catching the following part (which isn't the solution) in the transformer.ts:

try {
  const arrayModel = context.getModel(singularize(key));
  returnValue[key] = value.map(v => this.transformOutgoingData(arrayModel || model, v));
} catch (e) {
  returnValue[key] = value;
}

MLDMoritz avatar Jan 15 '19 13:01 MLDMoritz