Add nested nullable test in VariablesInAllowedPosition

This commit is contained in:
Vladimir Razuvaev 2018-08-22 17:55:42 +07:00
parent 804daa188e
commit 672ff0b7d6
2 changed files with 63 additions and 27 deletions

View File

@ -219,6 +219,14 @@ abstract class ValidatorTestCase extends TestCase
'type' => Type::string(), 'type' => Type::string(),
'args' => ['stringListArg' => ['type' => Type::listOf(Type::string())]], 'args' => ['stringListArg' => ['type' => Type::listOf(Type::string())]],
], ],
'stringListNonNullArgField' => [
'type' => Type::string(),
'args' => [
'stringListNonNullArg' => [
'type' => Type::listOf(Type::nonNull(Type::string())),
],
],
],
'complexArgField' => [ 'complexArgField' => [
'type' => Type::string(), 'type' => Type::string(),
'args' => ['complexArg' => ['type' => $ComplexInput]], 'args' => ['complexArg' => ['type' => $ComplexInput]],
@ -276,9 +284,15 @@ abstract class ValidatorTestCase extends TestCase
$anyScalar = new CustomScalarType([ $anyScalar = new CustomScalarType([
'name' => 'Any', 'name' => 'Any',
'serialize' => function ($value) { return $value; }, 'serialize' => function ($value) {
'parseLiteral' => function ($node) { return $node; }, // Allows any value return $value;
'parseValue' => function ($value) { return $value; }, // Allows any value },
'parseLiteral' => function ($node) {
return $node;
}, // Allows any value
'parseValue' => function ($value) {
return $value;
}, // Allows any value
]); ]);
$queryRoot = new ObjectType([ $queryRoot = new ObjectType([

View File

@ -368,4 +368,26 @@ class VariablesInAllowedPositionTest extends ValidatorTestCase
]); ]);
} }
/**
* @it [String] => [String!]
*/
public function testStringArrayXStringNonNullArray()
{
$this->expectFailsRule(
new VariablesInAllowedPosition,
'
query Query($stringListVar: [String])
{
complicatedArgs {
stringListNonNullArgField(stringListNonNullArg: $stringListVar)
}
}
', [
FormattedError::create(
VariablesInAllowedPosition::badVarPosMessage('stringListVar', '[String]', '[String!]'),
[new SourceLocation(2, 19), new SourceLocation(5, 59)]
)
]
);
}
} }