spring-projects / spring-data-rest

Simplifies building hypermedia-driven REST web services on top of Spring Data repositories
https://spring.io/projects/spring-data-rest
Apache License 2.0
920 stars 563 forks source link

Filtering resources feature #2315

Closed lowcasz closed 1 year ago

lowcasz commented 1 year ago

I think it is very needed feature and will make developing much easier. My implementation proposition is in the following example which adds "search" parameter into GET method and is very universal. Example: https://www.baeldung.com/rest-api-search-language-spring-data-specifications https://www.baeldung.com/rest-search-language-spring-jpa-criteria

In addition it can be more universal using other operators, or using url encoded value. Feauture of functions like "in()" can be added, joining queries with brackets, logical operators, string operators will be great too.

Creating additional methods in interfaces makes a lot of boilrerplate when we are thinking about null values.

In this search parameter we can use DSL, criteria API, JPQL, hibernate filters, or any other stuff. I leave it to discussion what is the best.

To sum up, builded in filtering feauture would be a great help in the development.

mp911de commented 1 year ago

Please either use Querydsl binding customizers or Spring GraphQL if you require more flexibility. We do not intend adding a custom query language on top of the HTTP API.