Requirements
- generic query language that can be used in GET requests to collection resources in REST api to filter the set of resources returned
- queries passed in via a "standard" query language and sent over HTTP as request parameter(s) - .e.g /someresource?query=...... or /someresource?a.b.c=2
- SQL queries constructed at runtime on the server
- tight integration with jpa, spring-data, spring-data-rest - the less code the better.
- nested resource and attribute paths available for queries
- support for complex operands - EQUALS, GREATER_THAN, LESS_THAN, NEGATION, LIKE, AND, OR, NOT, IN
E.g. resourceA.attribute1 = "CAT" AND resourceA.subResourceB.attribute2 >= 42 AND resourceA.attribute3 IN ("WHIZ","BANG")
I've investigated four solutions - each getting closer to the goal. Is there some other solution I haven't found or is there no such complete solution out of the box - is the answer to build upon the "REST query language with RSQL" outlined below?
1) spring-data-rest queries
There is plenty of support in spring data for developing complex queries in code, however this requires the developer to be aware of the structure of queries beforehand and to construct the code accordingly. https://docs.spring.io/spring-data/rest/docs/current/reference/html/#repository-resources.query-method-resource
2) spring-data, spring-data-rest, query-dsl
http://www.baeldung.com/rest-api-search-querydsl-web-in-spring-data-jpa
+ve An excellent fit - thoroughly capable solution with almost zero coding out of the box
+ve deeply nested queries can be constructed and the server generates correct SQL on the fly.
-ve the only operator is EQUALS '=' in order to apply additional operators you need to implement QuerydslBinderCustomizer instances which once again requires the server code to be aware of the complexity of the query in advance.
3) Baeldung - "building a rest query language"
http://www.baeldung.com/spring-rest-api-query-search-language-tutorial
- basic operations (EQUALS, GREATER_THAN, LESS_THAN)
http://www.baeldung.com/rest-api-search-language-spring-data-querydsl - advanced operations ((EQUALS, GREATER_THAN, LESS_THAN, NEGATION, LIKE) http://www.baeldung.com/rest-api-query-search-language-more-operations
- OR operator http://www.baeldung.com/rest-api-query-search-or-operation
+ve - getting closer to generic query language
-ve - feels like a demo / POC
4) REST Query Language with RSQL
http://www.baeldung.com/rest-api-search-language-rsql-fiql
+ve - feels like a more complete Query language & associated parser
-ve - unsure of spring integration