Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 300130

Add a public API for aliasing and disabling JSON:API resource type fields

$
0
0

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).


Viewing all articles
Browse latest Browse all 300130

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>