Skip to content

Commit 8a3d2b4

Browse files
committed
Consider variables in Mixed scalar
nuwave/lighthouse#2699
1 parent 0c38554 commit 8a3d2b4

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/MixedScalar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ public function parseValue($value)
2727

2828
public function parseLiteral($valueNode, ?array $variables = null)
2929
{
30-
return AST::valueFromASTUntyped($valueNode);
30+
return AST::valueFromASTUntyped($valueNode, $variables);
3131
}
3232
}

tests/MixedScalarTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,40 @@ public static function literalToPhpMap(): iterable
135135
];
136136
}
137137

138+
public function testIncludesVariablesInLiterals(): void
139+
{
140+
$query = /** @lang GraphQL */ '
141+
query ($a: Mixed, $b1: Mixed, $b3: Mixed) {
142+
foo(bar: {
143+
a: $a,
144+
bs: [$b1, 2, $b3]
145+
})
146+
}
147+
';
148+
149+
$result = GraphQL::executeQuery(
150+
$this->schema,
151+
$query,
152+
null,
153+
null,
154+
[
155+
'a' => 'foo',
156+
'b1' => 1,
157+
'b3' => 3,
158+
]
159+
);
160+
161+
self::assertSame(
162+
[
163+
'foo' => [
164+
'a' => 'foo',
165+
'bs' => [1, 2, 3],
166+
],
167+
],
168+
$result->data
169+
);
170+
}
171+
138172
private function executeQueryWithLiteral(string $literal): ExecutionResult
139173
{
140174
$query = /** @lang GraphQL */ "

0 commit comments

Comments
 (0)