druxt.js
druxt.js copied to clipboard
Add support for remapped resources.
As a user of Contenta I need schema support for remapped resources.
Contenta remaps some of the resources by default, which causes issues with relationships as well as ensuring a valid schema.
The JSON API resource config has all the relevant information to resolve the issue.
This issue was started in https://github.com/Realityloop/druxt-schema/issues/6, but the functionality belongs here so it can be used by other modules.
https://www.drupal.org/project/drupal/issues/3105318
There is a chance that the mapping will not be known from JSON:API Extras config. I'm working on adding the aliasing via code into Drupal core: https://www.drupal.org/project/drupal/issues/3105318
Originally posted by @mglaman in https://github.com/druxt/druxt-schema/issues/6#issuecomment-694486531
Thanks @mglaman,
I'm open to manual overrides as well, as that was the original intent myself.
You can see the existing work done towards this here: https://github.com/druxt/druxt-router/blob/4e1983e4ee13164893ab1db898e35f245c4027ba/src/router.js#L223-L243
Take into account that this will not support a lot of usecases, but it's a starting point.
Resources renamed using the JSON:API Extras module do work correctly, although there was a recent fix to the Druxt module for this that is still pending a version update: https://www.drupal.org/project/druxt/issues/3244770
However, resources renamed by the newly added renameResourceType method of the JSON:API Build event subscriber do not work as there's no central index to map the schema currently.