Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable filter query string parameters #3606

Closed
julienfalque opened this issue Jun 16, 2020 · 3 comments
Closed

Configurable filter query string parameters #3606

julienfalque opened this issue Jun 16, 2020 · 3 comments

Comments

@julienfalque
Copy link
Contributor

Filters use a single name as both the query string parameter and the underlying path to the filtered property. This ties the query string parameter to the underlying model: if the model changes, the parameter changes as well and its consumers must be updated. It also exposes internal details that the consumers might not have to be aware of.

I propose to allow setting different names for the query parameters by supporting passing an array of settings to filter properties configuration, e.g.:

before

services:
  foo.search_filter:
    parent: api_platform.doctrine.orm.search_filter
    arguments:
      -
        foo.bar.baz: exact

after

services:
  foo.search_filter:
    parent: api_platform.doctrine.orm.search_filter
    arguments:
      -
        baz:
          property: foo.bar.baz
          strategy: exact
@Jrobles-Oniad
Copy link

This would be great also to help comply https://jsonapi.org/recommendations/#filtering

@ihmels
Copy link
Contributor

ihmels commented Dec 22, 2021

Is that a feature you want to have in Core, @soyuka?

Currently I implemented this by extending from the Api Platform filters and adding an additional property to map the filter parameter name to the property (to keep the AbstractFilter::$properties property untouched). Then I override the constructor and the apply() and getDescription() methods to map the properties to their correspondending parameter name.

But I think this feature should be in Core, because then you can decouple the parameter names from the underlying model (like with DTOs plus Data Transformers).

@soyuka soyuka removed the help wanted label Nov 6, 2022
@soyuka
Copy link
Member

soyuka commented Oct 17, 2023

#2400

@soyuka soyuka closed this as completed Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants