diff --git a/src/MixedScalar.php b/src/MixedScalar.php index 8d6b37e..0076d66 100644 --- a/src/MixedScalar.php +++ b/src/MixedScalar.php @@ -27,6 +27,6 @@ public function parseValue($value) public function parseLiteral($valueNode, ?array $variables = null) { - return AST::valueFromASTUntyped($valueNode); + return AST::valueFromASTUntyped($valueNode, $variables); } } diff --git a/tests/MixedScalarTest.php b/tests/MixedScalarTest.php index 1a79a89..5178b1a 100644 --- a/tests/MixedScalarTest.php +++ b/tests/MixedScalarTest.php @@ -135,6 +135,40 @@ public static function literalToPhpMap(): iterable ]; } + public function testIncludesVariablesInLiterals(): void + { + $query = /** @lang GraphQL */ ' + query ($a: Mixed, $b1: Mixed, $b3: Mixed) { + foo(bar: { + a: $a, + bs: [$b1, 2, $b3] + }) + } + '; + + $result = GraphQL::executeQuery( + $this->schema, + $query, + null, + null, + [ + 'a' => 'foo', + 'b1' => 1, + 'b3' => 3, + ] + ); + + self::assertSame( + [ + 'foo' => [ + 'a' => 'foo', + 'bs' => [1, 2, 3], + ], + ], + $result->data + ); + } + private function executeQueryWithLiteral(string $literal): ExecutionResult { $query = /** @lang GraphQL */ "