api-platform / api-platform/core

Add @type or @context (or both) properties to Mercure data when object is deleted

Open
#8,062 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
2.6k
Forks
980
Avg merge
2d 4h
Merged PRs (30d)
49

Description

**Description**
Currently, the data of the Mercure update contains only the IRI of the removed object inside the `@id` property. This is enough for cases where topics are created for specific collections or items. More generic topics containing updates for several collections force the subscriber to parse the IRI to identify the affected collection. Unfortunately, for some collections, this requires writing a code which is difficult to maintain. An example of such an issue would be a collection of `Person` entities. The prefix for such entities is `/people/`. Adding the `@type` in the case of update/create events would make it easier for the subscriber to identify the affected collection.

**Example**
The `data` of the event would change from:
```
{"@id":"\/people\/1ed69b32-4697-68fc-9f20-e17dcbef2976"}
```
to:
```
{"@type":"Person", "@id":"\/people\/1ed69b32-4697-68fc-9f20-e17dcbef2976"}
```

I can create a PR if this is accepted.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.