-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
docs(filters): document enhanced QueryParameter syntax on old filters #2227
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
base: 4.2
Are you sure you want to change the base?
docs(filters): document enhanced QueryParameter syntax on old filters #2227
Conversation
… usage - Updated documentation to promote the `QueryParameter` attribute over `ApiFilter`, as the latter is deprecated and scheduled for removal in API Platform 5.0. - Added examples for Date, Boolean, Numeric, Range, Exists, and Order filters using the `QueryParameter` approach. Included notes on configuring custom strategies, handling null values, and enabling filters for nested properties.
1409cd7 to
4340fda
Compare
|
Thank you for improving the documentation. Please allow me to share my insights. In v4.2.3, when setting filters using - parameters: [
- 'search[:property]' => new QueryParameter(/* ... */)
+ parameters: [
+ new QueryParameter(key: 'search[:property]', /* ... */)Also, directly passing a filter instance to the For example, I have observed the following issues in my environment.
new QueryParameter(key: 'exists[content]', filter: new ExistsFilter(), property: 'content'),
new QueryParameter(key: 'exists[comments]', filter: new ExistsFilter(), property: 'comments'),
new QueryParameter(key: 'order[id]', filter: new OrderFilter(), property: 'id'),
new QueryParameter(key: 'order[date]', filter: new OrderFilter(), property: 'date'), |
| new GetCollection( | ||
| parameters: [ | ||
| // This WILL restrict to only title and author properties | ||
| // This WILL restricts to only title and author properties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // This WILL restricts to only title and author properties | |
| // This WILL restrict to only title and author properties |
restrict is a verb in this context
| #[GetCollection( | ||
| parameters: [ | ||
| // This WILL restrict to only title and author properties | ||
| // This WILL restricts to only title and author properties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // This WILL restricts to only title and author properties | |
| // This WILL restrict to only title and author properties |
Same as above
| tags: ['api_platform.filter'] | ||
| # The following are mandatory only if a _defaults section is defined with inverted values. | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the defaults section) | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) | |
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the "defaults" section) |
the section is actually called defaults
| tags: ['api_platform.filter'] | ||
| # The following are mandatory only if a _defaults section is defined with inverted values. | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the defaults section) | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) | |
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the "defaults" section) |
Same as above
| tags: ['api_platform.filter'] | ||
| # The following are mandatory only if a _defaults section is defined with inverted values. | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the defaults section) | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) | |
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the "defaults" section) |
| tags: ['api_platform.filter'] | ||
| # The following are mandatory only if a _defaults section is defined with inverted values. | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the defaults section) | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) | |
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the "defaults" section) |
| tags: ['api_platform.filter'] | ||
| # The following are mandatory only if a _defaults section is defined with inverted values. | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the defaults section) | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) | |
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the "defaults" section) |
| tags: ['api_platform.filter'] | ||
| # The following are mandatory only if a _defaults section is defined with inverted values. | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the defaults section) | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) | |
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the "defaults" section) |
| tags: ['api_platform.filter'] | ||
| # The following are mandatory only if a _defaults section is defined with inverted values. | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the defaults section) | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) | |
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the "defaults" section) |
| tags: ['api_platform.filter'] | ||
| # The following are mandatory only if a _defaults section is defined with inverted values. | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the defaults section) | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) | |
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the "defaults" section) |
| tags: ['api_platform.filter'] | ||
| # The following are mandatory only if a _defaults section is defined with inverted values. | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the defaults section) | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) | |
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the "defaults" section) |
| tags: ['api_platform.filter'] | ||
| # The following are mandatory only if a _defaults section is defined with inverted values. | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the defaults section) | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) | |
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the "defaults" section) |
| tags: ['api_platform.filter'] | ||
| # The following are mandatory only if a _defaults section is defined with inverted values. | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the defaults section) | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) | |
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the "defaults" section) |
| tags: ['api_platform.filter'] | ||
| # The following are mandatory only if a _defaults section is defined with inverted values. | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the defaults section) | ||
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the default section) | |
| # You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the "defaults" section) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
polish: I made a bunch of suggestions regarding spelling.
Completes #2203
And here to avoid these issues:
QueryParameter, it is not possible to set multiple filters for the same property core#7493:propertykey cannot be used inSearchFilter(Symfony only) core#7495Main changes:
QueryParameterapproach. Included notes on configuring custom strategies, handling null values, and enabling filters for nested properties.QueryParameterattribute overApiFilter, as the latter is deprecated and scheduled for removal in API Platform 5.0.