api-platform / api-platform/core

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

Aberta
#8,062 0 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
PHP
Estrelas
2.6k
Forks
980
Merge médio
2d 2h
PRs com merge (30d)
51

Descrição

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

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.