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

JSON:API POST/PATCH support for fully validatable config entities

$
0
0

Problem/Motivation

As an overall issue based on #2292707: GET on entity/taxonomy_vocabulary/{id} is not working it is weird we cannot POST/PATCH/DELETE for config entities.

This was a key reason for the JS Admin UI initiative being unable to proceed: the config it needed to modify was literally impossible to safely modify through APIs — the validation logic lived only in forms!

Proposed resolution

Remaining tasks

User interface changes

None.

API changes

  • Addition: \Drupal\Core\Entity\EntityConstraintViolationList now accepts not just FieldableEntityInterface but also ConfigEntityInterface
  • Addition: \Drupal\Core\Config\TypedConfigManager::getOriginalMappingType() (although we could do without; it'd just result in duplication of logic)
  • Change: ConfigEntityAdapter::validate() now returns an \Drupal\Core\Entity\EntityConstraintViolationList instead of a \Symfony\Component\Validator\ConstraintViolationList, to allow config and content entities to be treated consistently.
  • Addition: (@internal) \Drupal\jsonapi\Entity\EntityValidationTrait::validate() now also accepts ConfigEntityInterface and not just FieldableEntityInterface

⚠️ However, any contrib module that:

  1. provides a config entity type (common)
  2. subclasses \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase (uncommon)
  3. has made its config entity type fully validatable (rare)

… will start seeing their tests failing due to their test not yet providing a valid POST or PATCH document for their config entity (these tests were skipped automatically).

Release notes snippet

JSON:API now supports POSTing and PATCHing config entities that are fully validatable. This enables a whole new world of decoupled Drupal applications.


Viewing all articles
Browse latest Browse all 291503

Trending Articles



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