Skip to content

Commit 1aaf997

Browse files
committed
feat(graphql): Update getResourceId to handle scalar values
1 parent cea37ca commit 1aaf997

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/GraphQl/Subscription/SubscriptionManager.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,10 @@ private function encodeIriToCacheKey(string $iri): string
130130

131131
private function getResourceId(mixed $privateField, object $previousObject): string
132132
{
133-
$id = $previousObject->{'get'.ucfirst($privateField)}()->getId();
133+
$id = $previousObject->{'get'.ucfirst($privateField)}();
134+
if (is_object($id) && method_exists($id, 'getId')) {
135+
$id = $id->getId();
136+
}
134137
if ($id instanceof \Stringable || is_numeric($id)) {
135138
return (string) $id;
136139
}

src/Symfony/Doctrine/EventListener/PublishMercureUpdatesListener.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,10 @@ private function buildUpdate(string|array $iri, string $data, array $options): U
335335

336336
private function getResourceId(string $privateField, object $object): string
337337
{
338-
$id = $object->{'get'.ucfirst($privateField)}()->getId();
338+
$id = $object->{'get'.ucfirst($privateField)}();
339+
if (is_object($id) && method_exists($id, 'getId')) {
340+
$id = $id->getId();
341+
}
339342
if ($id instanceof \Stringable || is_numeric($id)) {
340343
return (string) $id;
341344
}

0 commit comments

Comments
 (0)