SAP / spartacus

Spartacus is a lean, Angular-based JavaScript storefront for SAP Commerce Cloud that communicates exclusively through the Commerce REST API.
Apache License 2.0
737 stars 381 forks source link

Search config serializer is not extendible #12381

Open mkbryla opened 3 years ago

mkbryla commented 3 years ago

Describe the bug Currently when fetching for example b2b user list, there is an entity added to the store with serialized query as a key. Unfortunately resposible for this is an util (so it can't be overrided) serializeSearchConfig and it has hardcoded returned params (pageSize, currentPage and sort only), which makes it unable to use with custom queryParams - for example when we change only the our new custom param the query will be the same (as hardcoded params won't change) and it won't make a call to fetch new data but just take value from store.

Tell us the version of Spartacus

Expected behavior Could this function for example instead having hardcoded string, just iterate through the passed searchConfig object keys and based on it create the entity name string?

Screenshots image

Pucek9 commented 3 years ago

it could be solved by use

return `${id ?? ''}?${Object.entries(config).map(([key, value]) => `${key}=${value}`).join('&')}`
Pucek9 commented 3 years ago

it could be solved by use

return `${id ?? ''}?${Object.entries(config).map(([key, value]) => `${key}=${value}`).join('&')}`

+ alphabetically sort of keys to make sure, that it's always the same ~Marcin