Skip to content

Commit e971e42

Browse files
committed
Small changes
1 parent ee44e18 commit e971e42

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* GraphQL: Add page-based pagination (#3175, #3517)
1010
* GraphQL: Possibility to add a custom description for queries, mutations and subscriptions (#3477, #3514)
1111
* GraphQL: Support for field name conversion (serialized name) (#3455, #3516)
12+
* GraphQL: **BC** `operation` is now `operationName` to follow the standard (#3568)
1213
* OpenAPI: Add PHP default values to the documentation (#2386)
1314
* Deprecate using a validation groups generator service not implementing `ApiPlatform\Core\Bridge\Symfony\Validator\ValidationGroupsGeneratorInterface` (#3346)
1415

@@ -34,7 +35,6 @@
3435
* HTTP: Location header is only set on POST with a 201 or between 300 and 400 #3497
3536
* GraphQL: Do not allow empty cursor values on `before` or `after` #3360
3637
* Bump versions of Swagger UI, GraphiQL and GraphQL Playground #3510
37-
>>>>>>> 2.5
3838

3939
## 2.5.4
4040

features/bootstrap/GraphqlContext.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ public function ISendTheGraphqlRequestWithVariables(PyStringNode $variables)
9090
}
9191

9292
/**
93-
* @When I send the GraphQL request with operation :operation
93+
* @When I send the GraphQL request with operationName :operationName
9494
*/
95-
public function ISendTheGraphqlRequestWithOperation(string $operation)
95+
public function ISendTheGraphqlRequestWithOperation(string $operationName)
9696
{
97-
$this->graphqlRequest['operation'] = $operation;
97+
$this->graphqlRequest['operationName'] = $operationName;
9898
$this->sendGraphqlRequest();
9999
}
100100

src/GraphQl/Action/EntrypointAction.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ public function __invoke(Request $request): Response
6969
}
7070
}
7171

72-
[$query, $operation, $variables] = $this->parseRequest($request);
72+
[$query, $operationName, $variables] = $this->parseRequest($request);
7373
if (null === $query) {
7474
throw new BadRequestHttpException('GraphQL query is not valid.');
7575
}
7676

7777
$executionResult = $this->executor
78-
->executeQuery($this->schemaBuilder->getSchema(), $query, null, null, $variables, $operation)
78+
->executeQuery($this->schemaBuilder->getSchema(), $query, null, null, $variables, $operationName)
7979
->setErrorFormatter([$this->normalizer, 'normalize']);
8080
} catch (\Exception $exception) {
8181
$executionResult = (new ExecutionResult(null, [new Error($exception->getMessage(), null, null, null, null, $exception)]))
@@ -91,34 +91,34 @@ public function __invoke(Request $request): Response
9191
private function parseRequest(Request $request): array
9292
{
9393
$query = $request->query->get('query');
94-
$operation = $request->query->get('operationName');
94+
$operationName = $request->query->get('operationName');
9595
if ($variables = $request->query->get('variables', [])) {
9696
$variables = $this->decodeVariables($variables);
9797
}
9898

9999
if (!$request->isMethod('POST')) {
100-
return [$query, $operation, $variables];
100+
return [$query, $operationName, $variables];
101101
}
102102

103103
if ('json' === $request->getContentType()) {
104-
return $this->parseData($query, $operation, $variables, $request->getContent());
104+
return $this->parseData($query, $operationName, $variables, $request->getContent());
105105
}
106106

107107
if ('graphql' === $request->getContentType()) {
108108
$query = $request->getContent();
109109
}
110110

111111
if ('multipart' === $request->getContentType()) {
112-
return $this->parseMultipartRequest($query, $operation, $variables, $request->request->all(), $request->files->all());
112+
return $this->parseMultipartRequest($query, $operationName, $variables, $request->request->all(), $request->files->all());
113113
}
114114

115-
return [$query, $operation, $variables];
115+
return [$query, $operationName, $variables];
116116
}
117117

118118
/**
119119
* @throws BadRequestHttpException
120120
*/
121-
private function parseData(?string $query, ?string $operation, array $variables, string $jsonContent): array
121+
private function parseData(?string $query, ?string $operationName, array $variables, string $jsonContent): array
122122
{
123123
if (!\is_array($data = json_decode($jsonContent, true))) {
124124
throw new BadRequestHttpException('GraphQL data is not valid JSON.');
@@ -133,23 +133,23 @@ private function parseData(?string $query, ?string $operation, array $variables,
133133
}
134134

135135
if (isset($data['operationName'])) {
136-
$operation = $data['operationName'];
136+
$operationName = $data['operationName'];
137137
}
138138

139-
return [$query, $operation, $variables];
139+
return [$query, $operationName, $variables];
140140
}
141141

142142
/**
143143
* @throws BadRequestHttpException
144144
*/
145-
private function parseMultipartRequest(?string $query, ?string $operation, array $variables, array $bodyParameters, array $files): array
145+
private function parseMultipartRequest(?string $query, ?string $operationName, array $variables, array $bodyParameters, array $files): array
146146
{
147147
if ((null === $operations = $bodyParameters['operations'] ?? null) || (null === $map = $bodyParameters['map'] ?? null)) {
148148
throw new BadRequestHttpException('GraphQL multipart request does not respect the specification.');
149149
}
150150

151151
/** @var string $operations */
152-
[$query, $operation, $variables] = $this->parseData($query, $operation, $variables, $operations);
152+
[$query, $operationName, $variables] = $this->parseData($query, $operationName, $variables, $operations);
153153

154154
/** @var string $map */
155155
if (!\is_array($decodedMap = json_decode($map, true))) {
@@ -158,7 +158,7 @@ private function parseMultipartRequest(?string $query, ?string $operation, array
158158

159159
$variables = $this->applyMapToVariables($decodedMap, $variables, $files);
160160

161-
return [$query, $operation, $variables];
161+
return [$query, $operationName, $variables];
162162
}
163163

164164
/**

0 commit comments

Comments
 (0)