Skip to content

Commit

Permalink
Merge 8a8728c into 8d7290e
Browse files Browse the repository at this point in the history
  • Loading branch information
alanpoulain committed Apr 23, 2020
2 parents 8d7290e + 8a8728c commit 2170a5b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
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
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
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

0 comments on commit 2170a5b

Please sign in to comment.