d34dman / drupal-jsonapi-params

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

add sql-like query strings for more convenience #9

Closed mathislucka closed 1 year ago

mathislucka commented 4 years ago

This implements a method allowing filters to be constructed from query strings.

It should mainly be more convenient and quicker to type for less complex filters.

Query strings can be written like so:

apiParams.addFilterQuery("pet = 'cat'")
apiParams.addFilterQuery("name CONTAINS 'Jo' memberOf first-name")
d34dman commented 4 years ago

@mathislucka thanks for the PR. This is an interesting concept.

So If i understand correctly,

apiParams.addFilter("pet", "cat") can be also written as, apiParams.addFilterQuery("pet = 'cat'")

apiParams.addFilter("name", "Jo", "CONTAINS", "first-name") can be also written as, apiParams.addFilterQuery("name CONTAINS 'Jo' memberOf first-name")

Following complications spring to my mind immediately:

Am trying to introduce placeholder support in upcoming release. After that I might pickup this feature request https://github.com/d34dman/drupal-jsonapi-params/issues/6 which lets you create DrupalJsonApiParams obj from previously encoded query object. I will keep this PR in mind, so that something like this could be introduced (but making no promises atm).

mathislucka commented 4 years ago

Yes, your understandig is correct.

I understand your concerns but I think I addressed these complications:

If the user does not pass the right amount of parameters or they have the wrong format an error will be thrown because addFilterQuery calls addFilter internally.

d34dman commented 1 year ago

This has been in the backlog for a while and am moving to won't fix. I feel this could be a different library that can depend on drupal-jsonapi-params and achieve the results. (With separate readme and features/bug tracking).