Skip to content

Conversation

@amenophis
Copy link
Contributor

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? not tested yet
Fixed tickets
License MIT
Doc PR

Hi,
I open this PR to start discuss about implementing a filter like provided in Loopback (http://loopback.io/doc/en/lb3/Where-filter.html).

The idea is to allow building complex query from client side like following examples:

http://localhost:8080/greetings?where[name][eq]=toto
http://localhost:8080/greetings?where[or][name][eq]=test&where[or][name][eq]=test
http://localhost:8080/greetings?where[and][name][eq]=test&where[and][id][lt]=10

TO-DO:

  • Make allowed fields configurable
  • Allow usage of sub resource fields
  • Write tests
  • Write documentation

I provide a first shoot implementation, wait for your comments !

@soyuka
Copy link
Member

soyuka commented Jun 29, 2018

Good ideas here also: https://postgrest.readthedocs.io/en/v5.0/api.html#

Copy link
Member

@dunglas dunglas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't wait to merge this feature. Some general feedback:

  • We use final and private by default
  • Is it possible to share some code between the new inner filters and the existing filters?

@dunglas
Copy link
Member

dunglas commented Jun 29, 2018

Actually, do you think it's possible to embed any existing or future filter in the where clause instead of recreating new ones? It would be more powerful and easier to maintain.

@amenophis
Copy link
Contributor Author

@dunglas, thinks it's a good idea, will try to use existing filters logic in this WhereFilter

@teohhanhui
Copy link
Contributor

Strongly -1 for a SQL-like Frankenfilter.

@dunglas
Copy link
Member

dunglas commented Jul 16, 2018

I like the name « FrankenFilter », but +1 to include it because:

  • it’s a feature frequently asked by our users since the very first release
  • it’s opt-in, nobody is forced to use it
  • it’s super convenient for admins (especially with GraphQL or the « properties » filter
  • alternative tools such as Loopback have it

However, we must write in bold in the documentation that this filter can be dangerous (DDOS vector) and should not be used for public APIs

@teohhanhui
Copy link
Contributor

teohhanhui commented Jul 16, 2018

The fact that it's a free-form filter is already a big no-no for me. But now that you mention the security risks, that makes it even worse.

But if we really want to do something like this, I wish we would stick to a format that is at least standardized, in other words OData.

@flug
Copy link
Contributor

flug commented Nov 14, 2019

@amenophis is this pull request still valid?

@soyuka
Copy link
Member

soyuka commented Nov 15, 2019

Let's keep this as-is while we wait to reach a consensus over #2400

@amenophis
Copy link
Contributor Author

Just rebased it and close outdated comments.

@silverbackdan
Copy link
Contributor

Hi, I was hoping to better understand #2400 composable issue and how it relates to this PR? These features seem to have been stale for just over a year.

Are there issues in this update which could not be resolved or have you just not had the time needed for this feature?

I only ask as the issue was brought to my attention by @alanpoulain while beginning another PR here #3924

@soyuka
Copy link
Member

soyuka commented Dec 31, 2020

see also api-platform/api-platform#1724 imo we need to pick or write a filter RFC and then work on it

Base automatically changed from master to main January 23, 2021 21:59
@soyuka soyuka removed the waiting label Feb 19, 2021
@metaclass-nl
Copy link

metaclass-nl commented May 29, 2021

I built a WhereFilter (FilterLogic) that reuses the existing ORM Filter classes and combines them with compound logic. If you don't like the way it manipulates the QueryBuilder (i don't): it can be combined with QueryExpressionGeneratorInterface (see my comment on RFC Filter composition), resulting in this branch.

@stale
Copy link

stale bot commented Nov 4, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Nov 4, 2022
@stale
Copy link

stale bot commented Jan 3, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 3, 2023
@stale stale bot closed this Jan 10, 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 this pull request may close these issues.

7 participants