[FEATURE] Use Jbuilder view rendering for expanding and shrinking JSON at runtime
Opened this issue · 1 comments
Is your feature request related to a problem? Please describe.
Currently, JSON for our event objects is generated in Models themselves. This is a bit odd as, ultimately, this is a view concern, not a model concern. Additionally, the Jbuilder view rendering tools allow you to use caching or portions.
That said, there's no way built into JBuilder to use the JBuilder view rendering if you're not returning it to the an HTTP controller. That said, it may be possible to create custom controller type, extracted from AbstractController in rails to use the JBuilder rendering functionality from there. You can then wrap it into some sort of code to hide the actual controller stuff.
Describe the solution you'd like
I'd like a mechanism that does something like this:
get_event_json(event, :list,:of, :expandable, :entities, :like, :nonprofit, :supporter, :etc)
which internally_calls /api/nonprofit/:nonprofit_id/object_events/:id
where :id = event.id
and returns the generated JSON with the given entities expanded (if any)
This could be used by the EventPublisher to pull details of the event objects.
Depends on #632
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
⏳ Alright! Looks like we need to wait for some dependencies:
💡 Don't worry, I will continue watching the list above and keep this comment updated. To add or remove a dependency please update this issue/PR description.
Brought to you by Dependent Issues (:robot: ). Happy coding!