Problem/Motivation
The JSON:API FieldResolver
was written prior to a lot of internal JSON:API refactoring. The biggest of which was the introduction of the ResourceType
value object which helps map Drupal's entity-based data model into a JSON:API resource object-based data model.
Part of the field resolver has already been refactored to use this value object, but FieldResolver::resolveInternalEntityQueryPath($entity_type_id, $bundle, $external_field_name)
has not been.
This shortcoming came up during Decoupled Days 2019 when a lot of interest was expressed for adding the ability to fetch all entities of a particular entity type, not just per-bundle. In other words, JSON:API does not currently have a /jsonapi/node
route, only /jsonapi/node/{bundle}
routes.
It was agreed that an experiment would be made in contrib to support his new feature. See https://www.drupal.org/project/jsonapi_cross_bundles. This refactoring would unblock that experiment in contrib (currently it requires a core patch/hack) while making the JSON:API module more internally consistent.
Proposed resolution
Refactor this:
FieldResolver::resolveInternalEntityQueryPath($entity_type_id, $bundle, $external_field_name)
into this:
FieldResolver::resolveInternalEntityQueryPath(ResourceType $resource_type, $external_field_name)
which would make that method match the already refactored method on the same class:
FieldResolver::resolveInternalIncludePath(ResourceType $resource_type, array $path_parts, $depth = 0)
User interface changes
None.
API changes
None. The field resolver is @internal
.
Data model changes
None.
Release notes snippet
N/A