Skip to content

Commit

Permalink
Merge pull request overblog#823 from edefimov/fix-symfony-5.2-depreca…
Browse files Browse the repository at this point in the history
…tion

Forward compatibility with symfony 6 at Parser
  • Loading branch information
mcg-web authored Apr 29, 2021
2 parents 04b0f56 + ca56914 commit 76d9443
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Request/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,14 @@ private function getParams(Request $request, array $data = []): array
static::PARAM_OPERATION_NAME => null,
];

// Keep a reference to the query-string
$qs = $request->query;
// Use all query parameters, since starting from Symfony 6 there will be an exception accessing array parameters
// via request->query->get(key), and another exception accessing non-array parameter via request->query->all(key)
$queryParameters = $request->query->all();

// Override request using query-string parameters
$query = $qs->has(static::PARAM_QUERY) ? $qs->get(static::PARAM_QUERY) : $data[static::PARAM_QUERY];
$variables = $qs->has(static::PARAM_VARIABLES) ? $qs->get(static::PARAM_VARIABLES) : $data[static::PARAM_VARIABLES];
$operationName = $qs->has(static::PARAM_OPERATION_NAME) ? $qs->get(static::PARAM_OPERATION_NAME) : $data[static::PARAM_OPERATION_NAME];
$query = $queryParameters[static::PARAM_QUERY] ?? $data[static::PARAM_QUERY];
$variables = $queryParameters[static::PARAM_VARIABLES] ?? $data[static::PARAM_VARIABLES];
$operationName = $queryParameters[static::PARAM_OPERATION_NAME] ?? $data[static::PARAM_OPERATION_NAME];

// `query` parameter is mandatory.
if (empty($query)) {
Expand Down

0 comments on commit 76d9443

Please sign in to comment.