Skip to content

Commit

Permalink
Merge 6dac5d3 into e16d86d
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincz committed Apr 3, 2024
2 parents e16d86d + 6dac5d3 commit 78042bf
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/Config/Parser/MetadataParser/MetadataParser.php
Expand Up @@ -976,10 +976,12 @@ private static function guessType(ReflectionClass $reflectionClass, Reflector $r
private static function guessArgs(
ReflectionClass $reflectionClass,
ReflectionMethod $method,
array $arguments,
array $currentArguments,
): array {
$arguments = [];
foreach ($method->getParameters() as $index => $parameter) {
if (array_key_exists($parameter->getName(), $arguments)) {
if (array_key_exists($parameter->getName(), $currentArguments)) {
$arguments[$parameter->getName()] = $currentArguments[$parameter->getName()];
continue;
}

Expand Down
13 changes: 12 additions & 1 deletion tests/Config/Parser/MetadataParserTest.php
Expand Up @@ -361,6 +361,17 @@ public function testProviders(): void
'access' => '@=default_access',
'public' => '@=default_public',
],
'planet_getNextPlanet' => [
'type' => 'Json',
'args' => [
'planetId' => ['type' => 'Int!'],
'minDistance' => ['type' => 'Int!'],
'maxDistance' => ['type' => 'Int!'],
],
'resolve' => "@=call(service('Overblog\\\\GraphQLBundle\\\\Tests\\\\Config\\\\Parser\\\\fixtures\\\\annotations\\\\Repository\\\\PlanetRepository').getNextPlanet, arguments({planetId: \"Int!\", minDistance: \"Int!\", maxDistance: \"Int!\"}, args))",
'access' => '@=default_access',
'public' => '@=default_public',
],
],
]);

Expand Down Expand Up @@ -475,7 +486,7 @@ public function testArgsAndReturnGuessing(): void
'away' => ['type' => 'Boolean', 'defaultValue' => false],
'maxDistance' => ['type' => 'Float', 'defaultValue' => null],
],
'resolve' => '@=call(value.getCasualties, arguments({raceId: "String!", areaId: "Int!", dayStart: "Int", dayEnd: "Int", nameStartingWith: "String", planet: "PlanetInput", away: "Boolean", maxDistance: "Float"}, args))',
'resolve' => '@=call(value.getCasualties, arguments({areaId: "Int!", raceId: "String!", dayStart: "Int", dayEnd: "Int", nameStartingWith: "String", planet: "PlanetInput", away: "Boolean", maxDistance: "Float"}, args))',
'complexity' => '@=childrenComplexity * 5',
],
],
Expand Down
Expand Up @@ -120,4 +120,22 @@ public function getArmorResistance(): int
{
return 10;
}

/**
* @GQL\Query(type="Json")
*
* @GQL\Arg(name="maxDistance", type="Int!")
* @GQL\Arg(name="planetId", type="Int!")
*/
#[GQL\Query(type: 'Json')]
#[GQL\Arg(name: 'maxDistance', type: 'Int!')]
#[GQL\Arg(name: 'planetId', type: 'Int!')]
public function getNextPlanet(int $planetId, int $minDistance, int $maxDistance): array
{
return [
'planetId' => $planetId,
'minDistance' => $minDistance,
'maxDistance' => $maxDistance,
];
}
}

0 comments on commit 78042bf

Please sign in to comment.