Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* MongoDB: Mercure support (#3290)
* GraphQL: Subscription support with Mercure (#3321)
* GraphQL: Allow to format GraphQL errors based on exceptions (#3063)
* GraphQL: Add page-based pagination (#3175)
* GraphQL: Add page-based pagination (#3175, #3517)
* GraphQL: Possibility to add a custom description for queries, mutations and subscriptions (#3477, #3514)
* GraphQL: Support for field name conversion (serialized name) (#3455, #3516)
* OpenAPI: Add PHP default values to the documentation (#2386)
Expand Down
11 changes: 11 additions & 0 deletions features/graphql/collection.feature
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ Feature: GraphQL collection support
fooDummies(page: 1) {
collection {
id
name
}
paginationInfo {
itemsPerPage
Expand All @@ -703,8 +704,11 @@ Feature: GraphQL collection support
And the response should be in JSON
And the JSON node "data.fooDummies.collection" should have 3 elements
And the JSON node "data.fooDummies.collection[0].id" should exist
And the JSON node "data.fooDummies.collection[0].name" should exist
And the JSON node "data.fooDummies.collection[1].id" should exist
And the JSON node "data.fooDummies.collection[1].name" should exist
And the JSON node "data.fooDummies.collection[2].id" should exist
And the JSON node "data.fooDummies.collection[2].name" should exist
And the JSON node "data.fooDummies.paginationInfo.itemsPerPage" should be equal to the number 3
And the JSON node "data.fooDummies.paginationInfo.lastPage" should be equal to the number 2
And the JSON node "data.fooDummies.paginationInfo.totalCount" should be equal to the number 5
Expand All @@ -714,6 +718,7 @@ Feature: GraphQL collection support
fooDummies(page: 2) {
collection {
id
name
}
}
}
Expand All @@ -727,6 +732,7 @@ Feature: GraphQL collection support
fooDummies(page: 3) {
collection {
id
name
}
}
}
Expand All @@ -744,6 +750,7 @@ Feature: GraphQL collection support
fooDummies(page: 1, itemsPerPage: 2) {
collection {
id
name
}
}
}
Expand All @@ -752,13 +759,16 @@ Feature: GraphQL collection support
And the response should be in JSON
And the JSON node "data.fooDummies.collection" should have 2 elements
And the JSON node "data.fooDummies.collection[0].id" should exist
And the JSON node "data.fooDummies.collection[0].name" should exist
And the JSON node "data.fooDummies.collection[1].id" should exist
And the JSON node "data.fooDummies.collection[1].name" should exist
When I send the following GraphQL request:
"""
{
fooDummies(page: 2, itemsPerPage: 2) {
collection {
id
name
}
}
}
Expand All @@ -772,6 +782,7 @@ Feature: GraphQL collection support
fooDummies(page: 3, itemsPerPage: 2) {
collection {
id
name
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQl/Serializer/SerializerContextBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private function fieldsToAttributes(?string $resourceClass, ?ResourceMetadata $r
$fields = $info->getFieldSelection(PHP_INT_MAX);
}

$attributes = $this->replaceIdKeys($fields['edges']['node'] ?? $fields, $resourceClass, $context);
$attributes = $this->replaceIdKeys($fields['edges']['node'] ?? $fields['collection'] ?? $fields, $resourceClass, $context);

if ($resolverContext['is_mutation'] || $resolverContext['is_subscription']) {
if (!$resourceMetadata) {
Expand Down