Problem/Motivation
Many sites are using the JSON:API Extras module to refine the API that JSON:API exposes by default. One such refinement is the ability to "alias" or disable resource type fields. To do that, JSON:API Extras is forced to depend on potentially unstable @internal
PHP code. Also, custom module developers aren't able to write logic that could automatically alias resource type fields according to rules that suit their application (like automatically alias field_foo_bar
to fooBar
).
Proposed resolution
Add the following methods to \Drupal\jsonapi\ResourceType\ResourceTypeBuildEvent
:
getFields() []ResourceTypeField
setPublicFieldName(ResourceTypeField $field, $public_field_name): void
disableField(ResourceTypeField $field): void
Remaining tasks
#3037039: Create a public API for indicating resource types should not be exposed
User interface changes
None.
API changes
There will be a new methods on an event.
Data model changes
None.
Release notes snippet
JSON:API resource type fields can now be aliased and disabled programmatically. See the change record (UPDATE THIS LINKED CR, IF POSSIBLE).