Skip to content

Commit b613923

Browse files
committed
fix(metadata): default graphql operations on ApiResource only
1 parent 80ac2e3 commit b613923

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Metadata/Resource/Factory/AttributesResourceMetadataCollectionFactory.php

+7
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ private function buildResourceOperations(array $attributes, string $resourceClas
8282
$resources = [];
8383
$index = -1;
8484
$operationPriority = 0;
85+
$hasApiResource = false;
8586

8687
foreach ($attributes as $attribute) {
8788
if (is_a($attribute->getName(), ApiResource::class, true)) {
89+
$hasApiResource = true;
8890
$resource = $this->getResourceWithDefaults($resourceClass, $shortName, $attribute->newInstance());
8991
$operations = [];
9092
foreach ($resource->getOperations() ?? new Operations() as $operation) {
@@ -140,6 +142,11 @@ private function buildResourceOperations(array $attributes, string $resourceClas
140142
}
141143

142144
if (null === $graphQlOperations) {
145+
if (!$hasApiResource) {
146+
$resources[$index] = $resources[$index]->withGraphQlOperations([]);
147+
continue;
148+
}
149+
143150
// Add default GraphQL operations on the first resource
144151
if (0 === $index) {
145152
$resources[$index] = $this->addDefaultGraphQlOperations($resources[$index]);

0 commit comments

Comments
 (0)