Closed (fixed)
Project:
JSON:API
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
31 Mar 2018 at 06:05 UTC
Updated:
13 Jul 2018 at 17:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
dawehnerComment #3
wim leersPosted this to #2952293-25: Branch next major: version 2, requiring Drupal core >=8.5.
Comment #4
gabesulliceI think we can skip the submodule part in 1.x and simply make a submodule that can be added to extras. Doing it in 1.x was simply a place for it to be developed while 1.x was the primary development branch of JSON API AFAICT.
Comment #5
e0ipsoI think it was also an assurance that this happens. To avoid just removing it and leaving the users that use this feature stranded until this is replicated elsewhere (for instance JSON API Extras).
Comment #6
gabesulliceLet's definitely not do that :)
Comment #7
wim leers+1
(I wrote this yesterday but my battery died :P)
Comment #8
wim leersI pledge that we will do the necessary work to bring this to JSON API Extras. I just did the same for the
EntityToJsonApiservice/functionality: #2982455: Add `jsonapi.entity.to_jsonapi` service.Comment #9
wim leers\Drupal\rest\Plugin\rest\resource\EntityResourcedoes this:So let's transplant that logic to JSON API. The logical place in JSON API is
ResourceTypeRepository, which creates immutableResourceTypevalue objects. That repository service already has aisLocatableResourceType()method, the result of which is stored in theResourceTypevalue object, its result accessible viaResourceType::isLocatable().So the logical solution is to add
ResourceTypeRepository::isValidatableResourceType()andResourceType::isValidatable(). This can then trivially be overridden by JSON API Extras!This patch adds that infrastructure. But doesn't actually use it yet.
Comment #10
wim leersThe first way we can use the infrastructure that #9 adds is to keep routes the same, but check it in the controller.
Comment #11
wim leersThe second way we can use the infrastructure that #9 adds is to modify the routes, which results in the routing system giving us 405 responses automatically. I personally prefer this, because there's fewer moving parts, we rely on the routing system to do what it's meant to do, and it keeps routes declarative.
Comment #12
wim leersI personally prefer #11, what do others prefer?
Both approaches make it super easy for JSON API Extras to override this:
Comment #13
gabesullice#11 is absolutely my preference also.
I feel like this isn't the right method name as it leaks a rather Drupal-specific implementation detail. We shouldn't really need to ask this question because all entities have a
validate()method, we just happen to know that it doesn't really work for some entity types.I'd rather see something more generic, like
isLocatable()andisMutable(). Validation should just be an internal precondition to being "mutable".I'd rather not see this override the existing HTTP methods and instead just set the correct methods at the get-go. This makes things easier to reason about.
I think you forgot to exclude POST on the collection route.
Comment #14
wim leers🤘
ResourceTypeisn't a public API, so it shouldn't matter anyway.ResourceType::isLocatable()is then similarly problematicResourceType::getEntityTypeId()is then even worseisMutable()works for me, I even considered that actually :D Will rename.WFM!
😅
Comment #15
wim leersThat was sloppy, sorry. 😳
Updated patch has zero mentions of
validatable. 👍Comment #16
gabesullice1. Resource type mirrors concepts to the specification, we should do the best we can I think :)
2. I thought locatable was actually quite nice. It's very spec-ish. URI vs. URL
3. I agree, let's fix that too then (2.x is our chance). Not here ofc.
Nit: this seems rather roundabout. First you add it then you remove it if something is not TRUE. What about:
👌
Comment #17
wim leers😳 OF COURSE 😳
Comment #18
wim leersCreated JSON API Extras issue to restore support for mutating config entities, includes patch: #2982664: Enable mutating of config entities in JSON API 2.x.
Comment #19
wim leersCR created: https://www.drupal.org/node/2982668.
Comment #20
gabesullice😘👌
Comment #25
wim leersCrediting everyone who participated in #2887313: JSON API indicates it supports POST/PATCH/DELETE of config entity types, but that's impossible.
Comment #27
wim leers