mirror of
https://github.com/retailcrm/graphql-php.git
synced 2025-02-11 10:09:24 +03:00
Add nested nullable test in VariablesInAllowedPosition
This commit is contained in:
parent
804daa188e
commit
672ff0b7d6
@ -28,7 +28,7 @@ abstract class ValidatorTestCase extends TestCase
|
|||||||
'fields' => [
|
'fields' => [
|
||||||
'name' => [
|
'name' => [
|
||||||
'type' => Type::string(),
|
'type' => Type::string(),
|
||||||
'args' => [ 'surname' => [ 'type' => Type::boolean() ] ]
|
'args' => ['surname' => ['type' => Type::boolean()]]
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
@ -38,14 +38,14 @@ abstract class ValidatorTestCase extends TestCase
|
|||||||
'fields' => [
|
'fields' => [
|
||||||
'name' => [
|
'name' => [
|
||||||
'type' => Type::string(),
|
'type' => Type::string(),
|
||||||
'args' => [ 'surname' => [ 'type' => Type::boolean() ] ]
|
'args' => ['surname' => ['type' => Type::boolean()]]
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$Canine = new InterfaceType([
|
$Canine = new InterfaceType([
|
||||||
'name' => 'Canine',
|
'name' => 'Canine',
|
||||||
'fields' => function() {
|
'fields' => function () {
|
||||||
return [
|
return [
|
||||||
'name' => [
|
'name' => [
|
||||||
'type' => Type::string(),
|
'type' => Type::string(),
|
||||||
@ -69,7 +69,7 @@ abstract class ValidatorTestCase extends TestCase
|
|||||||
'fields' => [
|
'fields' => [
|
||||||
'name' => [
|
'name' => [
|
||||||
'type' => Type::string(),
|
'type' => Type::string(),
|
||||||
'args' => [ 'surname' => [ 'type' => Type::boolean() ] ]
|
'args' => ['surname' => ['type' => Type::boolean()]]
|
||||||
],
|
],
|
||||||
'nickname' => ['type' => Type::string()],
|
'nickname' => ['type' => Type::string()],
|
||||||
'barkVolume' => ['type' => Type::int()],
|
'barkVolume' => ['type' => Type::int()],
|
||||||
@ -92,11 +92,11 @@ abstract class ValidatorTestCase extends TestCase
|
|||||||
|
|
||||||
$Cat = new ObjectType([
|
$Cat = new ObjectType([
|
||||||
'name' => 'Cat',
|
'name' => 'Cat',
|
||||||
'fields' => function() use (&$FurColor) {
|
'fields' => function () use (&$FurColor) {
|
||||||
return [
|
return [
|
||||||
'name' => [
|
'name' => [
|
||||||
'type' => Type::string(),
|
'type' => Type::string(),
|
||||||
'args' => [ 'surname' => [ 'type' => Type::boolean() ] ]
|
'args' => ['surname' => ['type' => Type::boolean()]]
|
||||||
],
|
],
|
||||||
'nickname' => ['type' => Type::string()],
|
'nickname' => ['type' => Type::string()],
|
||||||
'meows' => ['type' => Type::boolean()],
|
'meows' => ['type' => Type::boolean()],
|
||||||
@ -123,7 +123,7 @@ abstract class ValidatorTestCase extends TestCase
|
|||||||
$Human = new ObjectType([
|
$Human = new ObjectType([
|
||||||
'name' => 'Human',
|
'name' => 'Human',
|
||||||
'interfaces' => [$Being, $Intelligent],
|
'interfaces' => [$Being, $Intelligent],
|
||||||
'fields' => function() use (&$Human, $Pet) {
|
'fields' => function () use (&$Human, $Pet) {
|
||||||
return [
|
return [
|
||||||
'name' => [
|
'name' => [
|
||||||
'type' => Type::string(),
|
'type' => Type::string(),
|
||||||
@ -162,11 +162,11 @@ abstract class ValidatorTestCase extends TestCase
|
|||||||
$FurColor = new EnumType([
|
$FurColor = new EnumType([
|
||||||
'name' => 'FurColor',
|
'name' => 'FurColor',
|
||||||
'values' => [
|
'values' => [
|
||||||
'BROWN' => [ 'value' => 0 ],
|
'BROWN' => ['value' => 0],
|
||||||
'BLACK' => [ 'value' => 1 ],
|
'BLACK' => ['value' => 1],
|
||||||
'TAN' => [ 'value' => 2 ],
|
'TAN' => ['value' => 2],
|
||||||
'SPOTTED' => [ 'value' => 3 ],
|
'SPOTTED' => ['value' => 3],
|
||||||
'NO_FUR' => [ 'value' => null ],
|
'NO_FUR' => ['value' => null],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -193,41 +193,49 @@ abstract class ValidatorTestCase extends TestCase
|
|||||||
],
|
],
|
||||||
'nonNullIntArgField' => [
|
'nonNullIntArgField' => [
|
||||||
'type' => Type::string(),
|
'type' => Type::string(),
|
||||||
'args' => [ 'nonNullIntArg' => [ 'type' => Type::nonNull(Type::int())]],
|
'args' => ['nonNullIntArg' => ['type' => Type::nonNull(Type::int())]],
|
||||||
],
|
],
|
||||||
'stringArgField' => [
|
'stringArgField' => [
|
||||||
'type' => Type::string(),
|
'type' => Type::string(),
|
||||||
'args' => [ 'stringArg' => [ 'type' => Type::string()]],
|
'args' => ['stringArg' => ['type' => Type::string()]],
|
||||||
],
|
],
|
||||||
'booleanArgField' => [
|
'booleanArgField' => [
|
||||||
'type' => Type::string(),
|
'type' => Type::string(),
|
||||||
'args' => ['booleanArg' => [ 'type' => Type::boolean() ]],
|
'args' => ['booleanArg' => ['type' => Type::boolean()]],
|
||||||
],
|
],
|
||||||
'enumArgField' => [
|
'enumArgField' => [
|
||||||
'type' => Type::string(),
|
'type' => Type::string(),
|
||||||
'args' => [ 'enumArg' => ['type' => $FurColor ]],
|
'args' => ['enumArg' => ['type' => $FurColor]],
|
||||||
],
|
],
|
||||||
'floatArgField' => [
|
'floatArgField' => [
|
||||||
'type' => Type::string(),
|
'type' => Type::string(),
|
||||||
'args' => [ 'floatArg' => [ 'type' => Type::float()]],
|
'args' => ['floatArg' => ['type' => Type::float()]],
|
||||||
],
|
],
|
||||||
'idArgField' => [
|
'idArgField' => [
|
||||||
'type' => Type::string(),
|
'type' => Type::string(),
|
||||||
'args' => [ 'idArg' => [ 'type' => Type::id() ]],
|
'args' => ['idArg' => ['type' => Type::id()]],
|
||||||
],
|
],
|
||||||
'stringListArgField' => [
|
'stringListArgField' => [
|
||||||
'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]],
|
||||||
],
|
],
|
||||||
'multipleReqs' => [
|
'multipleReqs' => [
|
||||||
'type' => Type::string(),
|
'type' => Type::string(),
|
||||||
'args' => [
|
'args' => [
|
||||||
'req1' => [ 'type' => Type::nonNull(Type::int())],
|
'req1' => ['type' => Type::nonNull(Type::int())],
|
||||||
'req2' => [ 'type' => Type::nonNull(Type::int())],
|
'req2' => ['type' => Type::nonNull(Type::int())],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'multipleOpts' => [
|
'multipleOpts' => [
|
||||||
@ -246,8 +254,8 @@ abstract class ValidatorTestCase extends TestCase
|
|||||||
'multipleOptAndReq' => [
|
'multipleOptAndReq' => [
|
||||||
'type' => Type::string(),
|
'type' => Type::string(),
|
||||||
'args' => [
|
'args' => [
|
||||||
'req1' => [ 'type' => Type::nonNull(Type::int())],
|
'req1' => ['type' => Type::nonNull(Type::int())],
|
||||||
'req2' => [ 'type' => Type::nonNull(Type::int())],
|
'req2' => ['type' => Type::nonNull(Type::int())],
|
||||||
'opt1' => [
|
'opt1' => [
|
||||||
'type' => Type::int(),
|
'type' => Type::int(),
|
||||||
'defaultValue' => 0,
|
'defaultValue' => 0,
|
||||||
@ -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([
|
||||||
|
@ -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)]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user