Skip to content
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

Hints on tooling to implement 'partial responses via filtering' #806

Open
sareykaj opened this issue Apr 23, 2024 · 2 comments
Open

Hints on tooling to implement 'partial responses via filtering' #806

sareykaj opened this issue Apr 23, 2024 · 2 comments
Assignees

Comments

@sareykaj
Copy link

sareykaj commented Apr 23, 2024

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

@tkrop
Copy link
Member

tkrop commented May 2, 2024

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.

@sareykaj
Copy link
Author

sareykaj commented May 7, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants