-
Notifications
You must be signed in to change notification settings - Fork 203
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
On-demand REST resource embedding #1741
On-demand REST resource embedding #1741
Conversation
2656556
to
071196d
Compare
Looks good, insofar as less code to write, test and maintain. |
I like it ! 😄 |
Would it be possible to have a Loader implementation using |
2fe59ef
to
a9d6ff1
Compare
@pspanja I need to think about it again (it was like a month ago now), but in my vision of this architecture, yes, this was achievable. I'll be happy to discuss the details with you. |
I'm assuming @pspanja asks to be able to keep documents separated in Proxy cache to get best possible cache efficiency. One alternative we could explore is HTTP/2 server push, but I have no idea how Varnish behaves with that. At least with ESI it will be able to. It's just more tricky to get the resulting json(/xml..) document to be valid. |
Well, there are two main ways to see this:
Problem with 2 is that it doesn't really improve caching: the root resource that is requested will still be cached as a whole, still requiring multi-tagging. 1 is a solution I did think about when specifying this feature, but it has a few implications. The two main ones are making sure that the embedded payload is valid in the context of the parent (XML header for instance), and being able to specify the output format (XML/JSON) by means of an URL alone. We currently do it via the |
Refactored checking of expansion to a dedicated service, with use-cases in a unit-test: https://github.com/ezsystems/ezpublish-kernel/pull/1741/files#diff-675a7b1950edeb252504e0978c6065e4R50. It specifies how lists content expansion is requested, as well as automatic parent loading. |
7f3bc6e
to
dfcfe45
Compare
- `Content.Owner.Groups` | ||
|
||
### Permissions | ||
If the user doesn't have the required permissions to load an embedded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we have something a bit more explicit instead ? Also, it's not written anywhere but I guess the same will happen if for instance the embedded object has been removed (for instance the Owner of a Content Item) ? Ideally, the REST consumer should be able to differentiate those 2 cases. For instance, an attribute on the link would work well I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An attribute on the link is easy. Any preferred format/contents ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a TODO in any case.
68a9e26
to
428d52f
Compare
main location object embedded into the response: | ||
|
||
``` | ||
curl -X GET http://localhost:8000/api/ezp/v2/content/objects/1 -H 'Cookie: XDEBUG_SESSION=PHPSTORM' -H 'x-ez-embed-value: Content.MainLocation' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: You can remove 'Cookie: XDEBUG_SESSION=PHPSTORM'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point :-)
Based on a value object's REST URI, loads a value object using the controller action for this URI.
Used by ValueObjectVisitors to generate a link to a ValueObject. The visitor may expand the link to a full featured object.
Reverts an old refactoring: visiting a value object requires again that the visitor and generator are passed as arguments.
A decorator for the OutputGenerator that skips the root object element as well as its attributes.
4ea151e
to
83baf8b
Compare
83baf8b
to
77c6903
Compare
@pcardiga we should talk about it further, but I think that the feature can be tested by QA. It won't work for the time being with HTTP cache (as in cache will be stale until ttl expires on embed data), but we have planned on covering that with @andrerom's work. But meanwhile, the feature itself can be tested in order to check that it matches the specifications, I think. |
Just a note. We should not merge this until we started prototyping the JS Client (and also maybe platform UI) to benefit from this patch. We need to have a real feedback on its usage before having to keep BC on it for a long time. So before this has been done, I am -1 on merging this. |
It can not be merged (or at least used) before HTTP cache multi-tagging is implemented as well anyway, Yannick. |
The PR ezsystems/PlatformUIBundle#687 uses this branch. As written there, I think there are 2 issues:
|
main location object embedded into the response: | ||
|
||
``` | ||
curl -X GET http://localhost:8000/api/ezp/v2/content/objects/1 -H 'x-ez-embed-value: Content.MainLocation' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to instead use query param and align with JSON API? Or are there some implementation details that makes it hard to use query param?
As in:
curl -X GET http://localhost:8000/api/ezp/v2/content/objects/1?include=Content.MainLocation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(using header will make it hard to cache for instance)
Regarding the http/2 point earlier, it's pretty much here by now: https://blog.apisyouwonthate.com/lets-stop-building-apis-around-a-network-hack-9a68f7e83dd2 (a very oponionated blog, but worth the read to see how it could work) |
See the specification for a full technical description of the feature and its implementation.
TODO
HrefRestResourceLoader
?)Location.Content
loads aContentInfo
. The media-type attribute must be used for the value load request.x-ez-embed-value
header)stackPath
Content.Owner.MainLocation
implies automatic expansion ofOwner
first).ResourceLink
andResourceRouteReference
visitors$this->generator->generate()
calls in visitors that need replacingResourceRouteReference
UniqueUriValueLoader