Introduction

This module allows altering the resolved filter of the JSON:API endpoints.

How does this work?

This module alters the jsonapi.entity_resource service's controller class with a new one which extends it. This allows the creation of the hook_json_entity_filter_override_alter() which allows modules to change the resolved filter of the JSON:API endpoints.

How is this useful?

According to #3034701: Filtering users by role and an example provided in the documentation there was no way to filter entities based on a field referencing a configuration entity; at least until 9.3 where this got resolved (@see change record for more details).

This means that if running core < 9.3, you are not allowed to use filter[roles.id]=content_manager to retrieve all the users of the content_manager role since roles.id gets translated to roles.entity:user_role.uuid and Drupal's Entity API doesn't allow querying configuration entities (eg. user_role.uuid). The truth is though that we don't need to query configuration entities. We could just replace .entity:user_role.uuid with .target_id in the translation.

That's what this module does out of the box.

Configuration

No configuration is needed.

If you need to support other configuration entities than the user_roles, feel free to use the hook provided.

Why is this module not named JSON:API Configuration Entity Filter Override?

This was my original intention. But the override required for configuration entities also works for content entities.

Supporting organizations: 

Project information

  • caution Minimally maintained
    Maintainers monitor issues, but fast responses are not guaranteed.
  • caution No further development
    No longer developed by its maintainers.
  • Project categories: Developer tools
  • chart icon11 sites report using this module
  • Created by vensires on , updated
  • shieldStable releases for this project are covered by the security advisory policy.
    There are currently no supported stable releases.

Releases