vuestorefront / storefront-query-builder

ElasticSearch Query builder from the abstract "SearchQuery" object used by storefront-api, vue-storefront-api and vue-storefront projects
MIT License
7 stars 21 forks source link

Add extensibility features #3

Closed cewald closed 4 years ago

cewald commented 4 years ago

This might be the first step for extensibility features of #1.

I added a custom customFilters parameter to the buildQueryBodyFromSearchQuery method to add custom filters. This filters can be used like (important is the custom key to identify as custom filter):

searchQuery.applyFilter({ key: 'custom', value: 'filter_name', options: {  /* More complex options here */ } })

And the methods given to this customFilters parameter get a payload of parameters and work like:

({ name, options, queryChain, config }) => {
  // Do your custom filter stuff with the queryChain
  return queryChain
}
cewald commented 4 years ago

I will close this in favour of #6