Closed sareykaj closed 1 month ago
We actually have a Java/JavaScript
library for this, that was retracted already 5 to 6 years ago from Zalando's Open Source GH repository. It was using simple filtering on top of the response. However, we do not think that this is a proper approach to provide this feature, since it resolves much more information from the database than it needs to and is inherently inefficient.
Internally, we advise our developers - if possible - to filter the data at the source instead of applying a post filter at the response for efficiency. I also advise in talks and reviews to focus the usage of filter
-sets and embed
-combination for distinct high value use cases, where the effect compared to the effort and costs creates the maximum benefit.
Thanks a lot for you answer!
So an example of "filter the data at the source" would be to transform the fields query into an sql projection and then use e.g. Java Optional fields to filter out uninitialized fields in the response payload?
You mentioned filter
-sets. What do you mean with "sets"? Something predefined?
@sareykaj Yes, I used the term filter
-sets and embed
-combinations to describe that I suggest to provide a list of valid filter and embed keyword combinations that are supported instead of allowing the full might of the expression language defined. This is especially simple, if the properties that are disabled or enabled by the embed
or filter
are already structured into objects in the response.
Hi, I would like to implement 'partial responses via filtering' (using the fields query parameter) in my Spring Boot REST services but I could not find any Spring / Jackson build in functionality or add-on libraries to do it. As you refer to Spring/Java in your API guidelines in some places, I was wondering how you have implemented it. Best regards, Julian