Skip to content

[Feature Request] REST API Handler: Optional relationship ids in response #2111

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

Open
zupamario opened this issue May 6, 2025 · 2 comments
Open

Comments

@zupamario
Copy link

zupamario commented May 6, 2025

Our project uses the REST API handler. It worked well until recently when we noticed our requests loading slow. The reason was that every response always includes all relationship ids. This creates huge load on the database especially for models with a lot of relationships. Now that our project data has grow we really notice that. In almost all cases we do not really care for these ids so not loading them in the first place will be a huge improvement.

The problem could be solved by a parameter which can be set to disable the inclusion of the relationships ids. In this case only the relationship links would be included in the response. I tested it quickly by commenting out the following line in the REST API handler:

// include IDs of relation fields so that they can be serialized
this.includeRelationshipIds(type, args, 'include');

It would be really nice if you could wrap this line into an if statement based on a url parameter. Since I do not have a Zenstack development environment set up I think it would be easier if someone with Zenstack dev experience could help me implement this feature.

Thanks and regards

@ymc9
Copy link
Member

ymc9 commented May 20, 2025

Hi @zupamario , thanks for filing this. I think it makes sense to add it as an option to the RESTAPIHandler. Would you be interested in making a PR? I'll be happy to facilitate.

@zupamario
Copy link
Author

Hi ymc9,
Thanks for your response. Yes I'll try to create a PR for this.

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

No branches or pull requests

2 participants