Problem/Motivation

We've had to update the EntityToJsonApi service many times, both to fix flaws in the code and to keep in sync with upstream.

Proposed resolution

I've been wanting to change it to use subrequests for a while to solve this problem once and for all, since we then just rely on the upstream JSON:API module.

Last week, @e0ipso indicated he now agreed that it'd be better.

So let's do it!

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers created an issue. See original summary.

Wim Leers’s picture

This just came up again in #3032679-24: Clean-up: rename EntityCollection to Data. Rather than once again updating this service, this issue would remove the need for that change :)

e0ipso’s picture

I'm +1. I don't love the pattern, but it solves a real problem with maintenance.

Wim Leers’s picture

Assigned: Wim Leers » Unassigned
Status: Active » Needs review
FileSize
7.96 KB
e0ipso’s picture

I think we should construct the URL based on the route name. That's because the actual path may vary based on the JSON:API Extras configuration.

Additionally, would it make sense to have the subrequest processed as MASTER request? That way we can prime the page cache and leverage page cache.

e0ipso’s picture

Status: Needs review » Needs work
Wim Leers’s picture

That's because the actual path may vary based on the JSON:API Extras configuration.

I wanted to avoid coupling it to route name internal details, but I forgot about this. Great point! Will do.

Wim Leers’s picture

Status: Needs work » Needs review
FileSize
1.09 KB
8.08 KB

  • e0ipso committed 25f1d36 on 8.x-3.x authored by Wim Leers
    Issue #3035045 by Wim Leers, e0ipso: Make EntityToJsonApi use...
e0ipso’s picture

Status: Needs review » Fixed

Merged!

Wim Leers’s picture

🙏

sphism’s picture

@e0ipso just to let you know that a fresh install of Contenta hits this issue as soon as you view your content, it's not a good look :)

e0ipso’s picture

@sphism thanks for bringing it up. I know it is frustrating to update your project in the worst possible moment. Please be a bit more patient while the fixes trickle in.

sphism’s picture

@e0ipso no worries, I was just evaluating Contenta for a new project and as it stands right now this is a critical blocker from me using it, i.e. viewing any content returns nasty error... I tried to fix it but d8 is all pretty new to me and I couldn't get it to work at all.

e0ipso’s picture

This should be available to Contenta CMS and other distributions. 🎉

Wim Leers’s picture

🥳

sphism’s picture

awesome, i'll try out contenta again... although it looks like we'll be using straight d8 now

Wim Leers’s picture

#17: 🥳

miiimooo’s picture

I think it breaks now *because* it is done as a subrequest - see #3044925: Upgrade broke normalize in preprocess: LogicException: Render context is empty, because render() was called outside of a renderRoot() or renderPlain() call

Is there any point in reverting this? Either approach has complexity, but the subrequest involves the whole symfony request processing so it's difficult to diagnose or fix this there

Apologies, if this is not the place to report this.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.