Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
Revert "closes youshido-php#141"
Browse files Browse the repository at this point in the history
This reverts commit 38e7e4e.
  • Loading branch information
Sam Stenvall committed Oct 28, 2017
1 parent 914be49 commit 04380e4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
6 changes: 3 additions & 3 deletions Tests/Library/Validator/RequestValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class RequestValidatorTest extends \PHPUnit_Framework_TestCase
{

/**
* @expectedException \Youshido\GraphQL\Exception\Parser\InvalidRequestException
* @expectedException Youshido\GraphQL\Exception\Parser\InvalidRequestException
* @dataProvider invalidRequestProvider
*
* @param Request $request
Expand Down Expand Up @@ -102,7 +102,7 @@ public function invalidRequestProvider()
'variableReferences' => [
new VariableReference('test', null, new Location(1, 1))
]
], ['test' => 1])
])
],
[
new Request([
Expand All @@ -123,7 +123,7 @@ public function invalidRequestProvider()
new VariableReference('test', $variable1, new Location(1, 1)),
new VariableReference('test2', $variable2, new Location(1, 1))
]
], ['test' => 1, 'test2' => 2])
])
]
];
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/StarWars/StarWarsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testInvalidVariableType()
human(id: $someId) {
name
}
}', ['someId' => 1]
}'
);

$data = $processor->getResponseData();
Expand Down
17 changes: 3 additions & 14 deletions src/Execution/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

namespace Youshido\GraphQL\Execution;

use Youshido\GraphQL\Exception\Parser\InvalidRequestException;

use Youshido\GraphQL\Parser\Ast\ArgumentValue\Literal;
use Youshido\GraphQL\Parser\Ast\ArgumentValue\Variable;
use Youshido\GraphQL\Parser\Ast\ArgumentValue\VariableReference;
use Youshido\GraphQL\Parser\Ast\Fragment;
Expand Down Expand Up @@ -62,18 +63,6 @@ public function __construct($data = [], $variables = [])
}

if (array_key_exists('variableReferences', $data)) {
foreach ($data['variableReferences'] as $ref) {
if (!array_key_exists($ref->getName(), $variables)) {
/** @var Variable $variable */
$variable = $ref->getVariable();
if ($variable->hasDefaultValue()) {
$variables[$variable->getName()] = $variable->getDefaultValue()->getValue();
continue;
}
throw new InvalidRequestException(sprintf("Variable %s hasn't been submitted", $ref->getName()), $ref->getLocation());
}
}

$this->addVariableReferences($data['variableReferences']);
}

Expand Down Expand Up @@ -219,7 +208,7 @@ public function setVariables($variables)
}

$this->variables = $variables;
foreach ($this->variableReferences as $reference) {
foreach($this->variableReferences as $reference) {
/** invalid request with no variable */
if (!$reference->getVariable()) continue;
$variableName = $reference->getVariable()->getName();
Expand Down

0 comments on commit 04380e4

Please sign in to comment.