Skip to content

Commit 1d6444f

Browse files
authored
fix(graphql): use pagination types in BC layer (#4468)
1 parent db52758 commit 1d6444f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Core/GraphQl/Type/TypeBuilder.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,11 @@ public function getNodeInterface(): InterfaceType
196196
public function getResourcePaginatedCollectionType(GraphQLType $resourceType, string $resourceClass, string $operationName): GraphQLType
197197
{
198198
$shortName = $resourceType->name;
199+
$paginationType = $this->pagination->getGraphQlPaginationType($resourceClass, $operationName);
199200

200-
if ($this->typesContainer->has("{$shortName}Connection")) {
201-
return $this->typesContainer->get("{$shortName}Connection");
201+
$connectionTypeKey = sprintf('%s%sConnection', $shortName, ucfirst($paginationType));
202+
if ($this->typesContainer->has($connectionTypeKey)) {
203+
return $this->typesContainer->get($connectionTypeKey);
202204
}
203205

204206
$paginationType = $this->pagination->getGraphQlPaginationType($resourceClass, $operationName);
@@ -208,13 +210,13 @@ public function getResourcePaginatedCollectionType(GraphQLType $resourceType, st
208210
$this->getPageBasedPaginationFields($resourceType);
209211

210212
$configuration = [
211-
'name' => "{$shortName}Connection",
212-
'description' => "Connection for $shortName.",
213+
'name' => $connectionTypeKey,
214+
'description' => sprintf("%s connection for $shortName.", ucfirst($paginationType)),
213215
'fields' => $fields,
214216
];
215217

216218
$resourcePaginatedCollectionType = new ObjectType($configuration);
217-
$this->typesContainer->set("{$shortName}Connection", $resourcePaginatedCollectionType);
219+
$this->typesContainer->set($connectionTypeKey, $resourcePaginatedCollectionType);
218220

219221
return $resourcePaginatedCollectionType;
220222
}

0 commit comments

Comments
 (0)