d34dman / drupal-jsonapi-params

A package to manage json-api params
ISC License
59 stars 8 forks source link

qs Config customization #34

Closed rowrowrowrow closed 1 year ago

rowrowrowrow commented 1 year ago

We have the ability to customize the qs config used for stringifying but not for parsing.

Add the ability to customize for both and optionally add the ability to set a default qs config to use for all qs operations.

d34dman commented 1 year ago

Add the ability to customize for both and optionally add the ability to set a default qs config to use for all qs operations.

This would be quite a nice DX to have. We can have introduce some getters and setters for the qs options. Now that makes me wonder about how initializeWithQueryString and getQueryString would behave when additional options are send after setting some qs config.

We can, Option A. Override qs options when such parameters are present (making the behaviour consistent with how getQueryString behaves now) Option B. Deep merge both qs options in such a way that the one that got passed in wins when there are conflicting keys Option C. Replace qs options with the most recently passed options.

I am in favour of Option A, but what do you think?

rowrowrowrow commented 1 year ago

Yep, I prefer option A. If a user wants to pass different options they can use the getter to get the internal options, control how they are merged themselves, then pass in the preferred options as an override. Or they can just use the getters and setters to update the internal options as needed.

d34dman commented 1 year ago

Fixed in version 2.2.0