Problem/Motivation
We want to have entity level resources, so we can provide entity listings that are not segregated by bundle. This is specially interesting for decoupled administrative listings.
Proposed resolution
Have the normalizer to provide an output that contains only the entity field and the base fields. We want to have the lowest common denominator for what an entity schema looks like. By setting a flag in the context when serializing the entity we can avoid having the fields that are tied to the bundles. We can set that flag as an option in the route definition.
Important
This feature was reverted in #2755025: [CLEANUP] Refactor relationships to have a unified base class
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 2751527--entity-resources--10.patch | 13.52 KB | e0ipso |
| #6 | 2751527--entity-resources--6.patch | 24.35 KB | e0ipso |
Comments
Comment #2
e0ipsoThis is blocked by #2751525: [FEATURE] Move the resources to /{entity_type_id}/{bundle}/{id}.
Comment #3
e0ipsoComment #4
dawehnerIs it against JSONAPI to have more content than the schema defines? I mean there are usecases like site to site synchronizations where you might want to have a resource which just exposes every available item to full degree.
Comment #5
e0ipso@dawehner one of the things that I'm really considering is adding a Drupal specific link & relationship to the bundle level resource. Then you can do an include of the bundle specific resource. Something like:
That way we can have it both ways. What do you think?
Comment #6
e0ipsoThis patch creates the
/node/4resource. That resource will only have the data present in all the nodes, nothing specific to the actual bundle. We need a follow up to access all the fields in the bundle as a relationship.Comment #9
e0ipsoFollow up created: #2751985: [FEATURE] Add a bundle level relationship to entity level resources.
Comment #10
e0ipsoRe-roll
Comment #11
dawehnerNice idea!
Comment #13
e0ipsoComment #14
e0ipso