2015-07-15 20:05:46 +03:00
|
|
|
<?php
|
2016-11-26 22:48:01 +03:00
|
|
|
|
2018-09-01 18:07:06 +03:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2016-04-09 10:36:53 +03:00
|
|
|
namespace GraphQL\Tests\Executor;
|
2015-07-15 20:05:46 +03:00
|
|
|
|
2018-09-26 12:07:23 +03:00
|
|
|
use Exception;
|
2016-12-03 00:11:14 +03:00
|
|
|
use GraphQL\Deferred;
|
2018-09-01 18:07:06 +03:00
|
|
|
use GraphQL\Error\FormattedError;
|
2017-07-18 16:57:30 +03:00
|
|
|
use GraphQL\Error\UserError;
|
2016-04-09 10:36:53 +03:00
|
|
|
use GraphQL\Executor\Executor;
|
2015-07-15 20:05:46 +03:00
|
|
|
use GraphQL\Language\Parser;
|
|
|
|
use GraphQL\Language\SourceLocation;
|
|
|
|
use GraphQL\Type\Definition\ObjectType;
|
|
|
|
use GraphQL\Type\Definition\Type;
|
2018-09-01 18:07:06 +03:00
|
|
|
use GraphQL\Type\Schema;
|
2018-07-29 18:43:10 +03:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2015-07-15 20:05:46 +03:00
|
|
|
|
2018-07-29 18:43:10 +03:00
|
|
|
class NonNullTest extends TestCase
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
2018-09-26 12:07:23 +03:00
|
|
|
/** @var Exception */
|
2015-07-15 20:05:46 +03:00
|
|
|
public $syncError;
|
2016-10-18 18:15:21 +03:00
|
|
|
|
2018-09-26 12:07:23 +03:00
|
|
|
/** @var Exception */
|
2018-08-07 21:43:23 +03:00
|
|
|
public $syncNonNullError;
|
2016-11-26 22:48:01 +03:00
|
|
|
|
2018-09-26 12:07:23 +03:00
|
|
|
/** @var Exception */
|
2016-11-26 22:48:01 +03:00
|
|
|
public $promiseError;
|
|
|
|
|
2018-09-26 12:07:23 +03:00
|
|
|
/** @var Exception */
|
2018-08-07 21:43:23 +03:00
|
|
|
public $promiseNonNullError;
|
2016-11-26 22:48:01 +03:00
|
|
|
|
2018-09-01 18:07:06 +03:00
|
|
|
/** @var callable[] */
|
2015-07-15 20:05:46 +03:00
|
|
|
public $throwingData;
|
2018-09-01 18:07:06 +03:00
|
|
|
|
|
|
|
/** @var callable[] */
|
2015-07-15 20:05:46 +03:00
|
|
|
public $nullingData;
|
2018-09-01 18:07:06 +03:00
|
|
|
|
|
|
|
/** @var Schema */
|
2015-07-15 20:05:46 +03:00
|
|
|
public $schema;
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
2018-09-01 18:07:06 +03:00
|
|
|
$this->syncError = new UserError('sync');
|
|
|
|
$this->syncNonNullError = new UserError('syncNonNull');
|
|
|
|
$this->promiseError = new UserError('promise');
|
2018-08-07 21:43:23 +03:00
|
|
|
$this->promiseNonNullError = new UserError('promiseNonNull');
|
2015-07-15 20:05:46 +03:00
|
|
|
|
|
|
|
$this->throwingData = [
|
2018-09-01 18:07:06 +03:00
|
|
|
'sync' => function () {
|
2015-07-15 20:05:46 +03:00
|
|
|
throw $this->syncError;
|
|
|
|
},
|
2018-09-01 18:07:06 +03:00
|
|
|
'syncNonNull' => function () {
|
2018-08-07 21:43:23 +03:00
|
|
|
throw $this->syncNonNullError;
|
2015-07-15 20:05:46 +03:00
|
|
|
},
|
2018-09-01 18:07:06 +03:00
|
|
|
'promise' => function () {
|
2016-12-03 00:11:14 +03:00
|
|
|
return new Deferred(function () {
|
2016-11-26 22:48:01 +03:00
|
|
|
throw $this->promiseError;
|
|
|
|
});
|
|
|
|
},
|
2018-09-01 18:07:06 +03:00
|
|
|
'promiseNonNull' => function () {
|
2016-12-03 00:11:14 +03:00
|
|
|
return new Deferred(function () {
|
2018-08-07 21:43:23 +03:00
|
|
|
throw $this->promiseNonNullError;
|
2016-11-26 22:48:01 +03:00
|
|
|
});
|
|
|
|
},
|
2018-09-01 18:07:06 +03:00
|
|
|
'syncNest' => function () {
|
2015-07-15 20:05:46 +03:00
|
|
|
return $this->throwingData;
|
|
|
|
},
|
2018-09-01 18:07:06 +03:00
|
|
|
'syncNonNullNest' => function () {
|
2015-07-15 20:05:46 +03:00
|
|
|
return $this->throwingData;
|
|
|
|
},
|
2018-09-01 18:07:06 +03:00
|
|
|
'promiseNest' => function () {
|
2016-12-03 00:11:14 +03:00
|
|
|
return new Deferred(function () {
|
|
|
|
return $this->throwingData;
|
2016-11-26 22:48:01 +03:00
|
|
|
});
|
|
|
|
},
|
2018-08-07 21:43:23 +03:00
|
|
|
'promiseNonNullNest' => function () {
|
2016-12-03 00:11:14 +03:00
|
|
|
return new Deferred(function () {
|
|
|
|
return $this->throwingData;
|
2016-11-26 22:48:01 +03:00
|
|
|
});
|
|
|
|
},
|
2015-07-15 20:05:46 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
$this->nullingData = [
|
2018-09-26 12:07:23 +03:00
|
|
|
'sync' => static function () {
|
2015-07-15 20:05:46 +03:00
|
|
|
return null;
|
|
|
|
},
|
2018-09-26 12:07:23 +03:00
|
|
|
'syncNonNull' => static function () {
|
2015-07-15 20:05:46 +03:00
|
|
|
return null;
|
|
|
|
},
|
2018-09-26 12:07:23 +03:00
|
|
|
'promise' => static function () {
|
|
|
|
return new Deferred(static function () {
|
2016-12-03 00:11:14 +03:00
|
|
|
return null;
|
2016-11-26 22:48:01 +03:00
|
|
|
});
|
|
|
|
},
|
2018-09-26 12:07:23 +03:00
|
|
|
'promiseNonNull' => static function () {
|
|
|
|
return new Deferred(static function () {
|
2016-12-03 00:11:14 +03:00
|
|
|
return null;
|
2016-11-26 22:48:01 +03:00
|
|
|
});
|
|
|
|
},
|
2018-09-01 18:07:06 +03:00
|
|
|
'syncNest' => function () {
|
2015-07-15 20:05:46 +03:00
|
|
|
return $this->nullingData;
|
|
|
|
},
|
2018-09-01 18:07:06 +03:00
|
|
|
'syncNonNullNest' => function () {
|
2015-07-15 20:05:46 +03:00
|
|
|
return $this->nullingData;
|
|
|
|
},
|
2018-09-01 18:07:06 +03:00
|
|
|
'promiseNest' => function () {
|
2016-12-03 00:11:14 +03:00
|
|
|
return new Deferred(function () {
|
|
|
|
return $this->nullingData;
|
2016-11-26 22:48:01 +03:00
|
|
|
});
|
|
|
|
},
|
2018-08-07 21:43:23 +03:00
|
|
|
'promiseNonNullNest' => function () {
|
2016-12-03 00:11:14 +03:00
|
|
|
return new Deferred(function () {
|
|
|
|
return $this->nullingData;
|
2016-11-26 22:48:01 +03:00
|
|
|
});
|
|
|
|
},
|
2015-07-15 20:05:46 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
$dataType = new ObjectType([
|
2018-09-01 18:07:06 +03:00
|
|
|
'name' => 'DataType',
|
2018-09-26 12:07:23 +03:00
|
|
|
'fields' => static function () use (&$dataType) {
|
2016-10-22 20:49:25 +03:00
|
|
|
return [
|
2018-09-01 18:07:06 +03:00
|
|
|
'sync' => ['type' => Type::string()],
|
|
|
|
'syncNonNull' => ['type' => Type::nonNull(Type::string())],
|
|
|
|
'promise' => Type::string(),
|
|
|
|
'promiseNonNull' => Type::nonNull(Type::string()),
|
|
|
|
'syncNest' => $dataType,
|
|
|
|
'syncNonNullNest' => Type::nonNull($dataType),
|
|
|
|
'promiseNest' => $dataType,
|
2018-08-07 21:43:23 +03:00
|
|
|
'promiseNonNullNest' => Type::nonNull($dataType),
|
2016-10-22 20:49:25 +03:00
|
|
|
];
|
2018-09-01 18:07:06 +03:00
|
|
|
},
|
2015-07-15 20:05:46 +03:00
|
|
|
]);
|
|
|
|
|
2016-05-02 00:42:05 +03:00
|
|
|
$this->schema = new Schema(['query' => $dataType]);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Execute: handles non-nullable types
|
2016-05-02 00:42:05 +03:00
|
|
|
|
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('nulls a nullable field that throws synchronously')
|
2016-05-02 00:42:05 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testNullsANullableFieldThatThrowsSynchronously() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
|
|
|
$doc = '
|
|
|
|
query Q {
|
|
|
|
sync
|
|
|
|
}
|
|
|
|
';
|
|
|
|
|
|
|
|
$ast = Parser::parse($doc);
|
|
|
|
|
|
|
|
$expected = [
|
2018-09-01 18:07:06 +03:00
|
|
|
'data' => ['sync' => null],
|
2015-07-15 20:05:46 +03:00
|
|
|
'errors' => [
|
2015-08-17 17:01:55 +03:00
|
|
|
FormattedError::create(
|
2016-10-18 18:15:21 +03:00
|
|
|
$this->syncError->getMessage(),
|
2015-07-15 20:05:46 +03:00
|
|
|
[new SourceLocation(3, 9)]
|
2018-09-01 18:07:06 +03:00
|
|
|
),
|
|
|
|
],
|
2015-07-15 20:05:46 +03:00
|
|
|
];
|
2018-09-19 18:12:09 +03:00
|
|
|
self::assertArraySubset(
|
2018-09-01 18:07:06 +03:00
|
|
|
$expected,
|
|
|
|
Executor::execute($this->schema, $ast, $this->throwingData, null, [], 'Q')->toArray()
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testNullsANullableFieldThatThrowsInAPromise() : void
|
2016-11-26 22:48:01 +03:00
|
|
|
{
|
|
|
|
$doc = '
|
|
|
|
query Q {
|
|
|
|
promise
|
|
|
|
}
|
|
|
|
';
|
|
|
|
|
|
|
|
$ast = Parser::parse($doc);
|
|
|
|
|
|
|
|
$expected = [
|
2018-09-01 18:07:06 +03:00
|
|
|
'data' => ['promise' => null],
|
2016-11-26 22:48:01 +03:00
|
|
|
'errors' => [
|
|
|
|
FormattedError::create(
|
|
|
|
$this->promiseError->getMessage(),
|
|
|
|
[new SourceLocation(3, 9)]
|
2018-09-01 18:07:06 +03:00
|
|
|
),
|
|
|
|
],
|
2016-11-26 22:48:01 +03:00
|
|
|
];
|
|
|
|
|
2018-09-19 18:12:09 +03:00
|
|
|
self::assertArraySubset(
|
2018-09-01 18:07:06 +03:00
|
|
|
$expected,
|
|
|
|
Executor::execute($this->schema, $ast, $this->throwingData, null, [], 'Q')->toArray()
|
|
|
|
);
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testNullsASynchronouslyReturnedObjectThatContainsANonNullableFieldThatThrowsSynchronously() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
|
|
|
// nulls a synchronously returned object that contains a non-nullable field that throws synchronously
|
|
|
|
$doc = '
|
|
|
|
query Q {
|
2018-08-07 21:43:23 +03:00
|
|
|
syncNest {
|
|
|
|
syncNonNull,
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
';
|
|
|
|
|
|
|
|
$ast = Parser::parse($doc);
|
|
|
|
|
|
|
|
$expected = [
|
2018-09-01 18:07:06 +03:00
|
|
|
'data' => ['syncNest' => null],
|
2015-07-15 20:05:46 +03:00
|
|
|
'errors' => [
|
2018-09-01 18:07:06 +03:00
|
|
|
FormattedError::create($this->syncNonNullError->getMessage(), [new SourceLocation(4, 11)]),
|
|
|
|
],
|
2015-07-15 20:05:46 +03:00
|
|
|
];
|
2018-09-19 18:12:09 +03:00
|
|
|
self::assertArraySubset(
|
2018-09-01 18:07:06 +03:00
|
|
|
$expected,
|
|
|
|
Executor::execute($this->schema, $ast, $this->throwingData, null, [], 'Q')->toArray()
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testNullsAsynchronouslyReturnedObjectThatContainsANonNullableFieldThatThrowsInAPromise() : void
|
2016-11-26 22:48:01 +03:00
|
|
|
{
|
|
|
|
$doc = '
|
|
|
|
query Q {
|
2018-08-07 21:43:23 +03:00
|
|
|
syncNest {
|
|
|
|
promiseNonNull,
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
';
|
|
|
|
|
|
|
|
$ast = Parser::parse($doc);
|
|
|
|
|
|
|
|
$expected = [
|
2018-09-01 18:07:06 +03:00
|
|
|
'data' => ['syncNest' => null],
|
2016-11-26 22:48:01 +03:00
|
|
|
'errors' => [
|
2018-09-01 18:07:06 +03:00
|
|
|
FormattedError::create($this->promiseNonNullError->getMessage(), [new SourceLocation(4, 11)]),
|
|
|
|
],
|
2016-11-26 22:48:01 +03:00
|
|
|
];
|
|
|
|
|
2018-09-19 18:12:09 +03:00
|
|
|
self::assertArraySubset(
|
2018-09-01 18:07:06 +03:00
|
|
|
$expected,
|
|
|
|
Executor::execute($this->schema, $ast, $this->throwingData, null, [], 'Q')->toArray()
|
|
|
|
);
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testNullsAnObjectReturnedInAPromiseThatContainsANonNullableFieldThatThrowsSynchronously() : void
|
2016-11-26 22:48:01 +03:00
|
|
|
{
|
|
|
|
$doc = '
|
|
|
|
query Q {
|
|
|
|
promiseNest {
|
2018-08-07 21:43:23 +03:00
|
|
|
syncNonNull,
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
';
|
|
|
|
|
|
|
|
$ast = Parser::parse($doc);
|
|
|
|
|
|
|
|
$expected = [
|
2018-09-01 18:07:06 +03:00
|
|
|
'data' => ['promiseNest' => null],
|
2016-11-26 22:48:01 +03:00
|
|
|
'errors' => [
|
2018-09-01 18:07:06 +03:00
|
|
|
FormattedError::create($this->syncNonNullError->getMessage(), [new SourceLocation(4, 11)]),
|
|
|
|
],
|
2016-11-26 22:48:01 +03:00
|
|
|
];
|
|
|
|
|
2018-09-19 18:12:09 +03:00
|
|
|
self::assertArraySubset(
|
2018-09-01 18:07:06 +03:00
|
|
|
$expected,
|
|
|
|
Executor::execute($this->schema, $ast, $this->throwingData, null, [], 'Q')->toArray()
|
|
|
|
);
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testNullsAnObjectReturnedInAPromiseThatContainsANonNullableFieldThatThrowsInAPromise() : void
|
2016-11-26 22:48:01 +03:00
|
|
|
{
|
|
|
|
$doc = '
|
|
|
|
query Q {
|
|
|
|
promiseNest {
|
2018-08-07 21:43:23 +03:00
|
|
|
promiseNonNull,
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
';
|
|
|
|
|
|
|
|
$ast = Parser::parse($doc);
|
|
|
|
|
|
|
|
$expected = [
|
2018-09-01 18:07:06 +03:00
|
|
|
'data' => ['promiseNest' => null],
|
2016-11-26 22:48:01 +03:00
|
|
|
'errors' => [
|
2018-09-01 18:07:06 +03:00
|
|
|
FormattedError::create($this->promiseNonNullError->getMessage(), [new SourceLocation(4, 11)]),
|
|
|
|
],
|
2016-11-26 22:48:01 +03:00
|
|
|
];
|
|
|
|
|
2018-09-19 18:12:09 +03:00
|
|
|
self::assertArraySubset(
|
2018-09-01 18:07:06 +03:00
|
|
|
$expected,
|
|
|
|
Executor::execute($this->schema, $ast, $this->throwingData, null, [], 'Q')->toArray()
|
|
|
|
);
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
|
2016-12-03 00:11:14 +03:00
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('nulls a complex tree of nullable fields that throw')
|
2016-12-03 00:11:14 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testNullsAComplexTreeOfNullableFieldsThatThrow() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
|
|
|
$doc = '
|
|
|
|
query Q {
|
2018-08-07 21:43:23 +03:00
|
|
|
syncNest {
|
2015-07-15 20:05:46 +03:00
|
|
|
sync
|
2016-11-26 22:48:01 +03:00
|
|
|
promise
|
2018-08-07 21:43:23 +03:00
|
|
|
syncNest {
|
2016-11-26 22:48:01 +03:00
|
|
|
sync
|
|
|
|
promise
|
|
|
|
}
|
|
|
|
promiseNest {
|
|
|
|
sync
|
|
|
|
promise
|
|
|
|
}
|
|
|
|
}
|
|
|
|
promiseNest {
|
|
|
|
sync
|
|
|
|
promise
|
2018-08-07 21:43:23 +03:00
|
|
|
syncNest {
|
2015-07-15 20:05:46 +03:00
|
|
|
sync
|
2016-11-26 22:48:01 +03:00
|
|
|
promise
|
|
|
|
}
|
|
|
|
promiseNest {
|
|
|
|
sync
|
|
|
|
promise
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-11-26 22:48:01 +03:00
|
|
|
';
|
2015-07-15 20:05:46 +03:00
|
|
|
|
|
|
|
$ast = Parser::parse($doc);
|
|
|
|
|
|
|
|
$expected = [
|
2018-09-01 18:07:06 +03:00
|
|
|
'data' => [
|
|
|
|
'syncNest' => [
|
|
|
|
'sync' => null,
|
|
|
|
'promise' => null,
|
|
|
|
'syncNest' => [
|
|
|
|
'sync' => null,
|
2016-11-26 22:48:01 +03:00
|
|
|
'promise' => null,
|
|
|
|
],
|
|
|
|
'promiseNest' => [
|
2018-09-01 18:07:06 +03:00
|
|
|
'sync' => null,
|
2016-11-26 22:48:01 +03:00
|
|
|
'promise' => null,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'promiseNest' => [
|
2018-09-01 18:07:06 +03:00
|
|
|
'sync' => null,
|
|
|
|
'promise' => null,
|
|
|
|
'syncNest' => [
|
|
|
|
'sync' => null,
|
2016-11-26 22:48:01 +03:00
|
|
|
'promise' => null,
|
|
|
|
],
|
|
|
|
'promiseNest' => [
|
2018-09-01 18:07:06 +03:00
|
|
|
'sync' => null,
|
2016-11-26 22:48:01 +03:00
|
|
|
'promise' => null,
|
|
|
|
],
|
|
|
|
],
|
2015-07-15 20:05:46 +03:00
|
|
|
],
|
|
|
|
'errors' => [
|
2016-10-18 18:15:21 +03:00
|
|
|
FormattedError::create($this->syncError->getMessage(), [new SourceLocation(4, 11)]),
|
2016-11-26 22:48:01 +03:00
|
|
|
FormattedError::create($this->syncError->getMessage(), [new SourceLocation(7, 13)]),
|
|
|
|
FormattedError::create($this->syncError->getMessage(), [new SourceLocation(11, 13)]),
|
|
|
|
FormattedError::create($this->syncError->getMessage(), [new SourceLocation(16, 11)]),
|
|
|
|
FormattedError::create($this->syncError->getMessage(), [new SourceLocation(19, 13)]),
|
2016-12-03 00:11:14 +03:00
|
|
|
FormattedError::create($this->promiseError->getMessage(), [new SourceLocation(5, 11)]),
|
|
|
|
FormattedError::create($this->promiseError->getMessage(), [new SourceLocation(8, 13)]),
|
2016-12-17 01:14:51 +03:00
|
|
|
FormattedError::create($this->syncError->getMessage(), [new SourceLocation(23, 13)]),
|
2016-12-03 00:11:14 +03:00
|
|
|
FormattedError::create($this->promiseError->getMessage(), [new SourceLocation(12, 13)]),
|
|
|
|
FormattedError::create($this->promiseError->getMessage(), [new SourceLocation(17, 11)]),
|
|
|
|
FormattedError::create($this->promiseError->getMessage(), [new SourceLocation(20, 13)]),
|
2016-11-26 22:48:01 +03:00
|
|
|
FormattedError::create($this->promiseError->getMessage(), [new SourceLocation(24, 13)]),
|
2018-09-01 18:07:06 +03:00
|
|
|
],
|
2015-07-15 20:05:46 +03:00
|
|
|
];
|
2016-11-26 22:48:01 +03:00
|
|
|
|
2018-09-19 18:12:09 +03:00
|
|
|
self::assertArraySubset(
|
2018-09-01 18:07:06 +03:00
|
|
|
$expected,
|
|
|
|
Executor::execute($this->schema, $ast, $this->throwingData, null, [], 'Q')->toArray()
|
|
|
|
);
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testNullsTheFirstNullableObjectAfterAFieldThrowsInALongChainOfFieldsThatAreNonNull() : void
|
2016-11-26 22:48:01 +03:00
|
|
|
{
|
|
|
|
$doc = '
|
|
|
|
query Q {
|
2018-08-07 21:43:23 +03:00
|
|
|
syncNest {
|
|
|
|
syncNonNullNest {
|
|
|
|
promiseNonNullNest {
|
|
|
|
syncNonNullNest {
|
|
|
|
promiseNonNullNest {
|
|
|
|
syncNonNull
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
promiseNest {
|
2018-08-07 21:43:23 +03:00
|
|
|
syncNonNullNest {
|
|
|
|
promiseNonNullNest {
|
|
|
|
syncNonNullNest {
|
|
|
|
promiseNonNullNest {
|
|
|
|
syncNonNull
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-08-07 21:43:23 +03:00
|
|
|
anotherNest: syncNest {
|
|
|
|
syncNonNullNest {
|
|
|
|
promiseNonNullNest {
|
|
|
|
syncNonNullNest {
|
|
|
|
promiseNonNullNest {
|
|
|
|
promiseNonNull
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
anotherPromiseNest: promiseNest {
|
2018-08-07 21:43:23 +03:00
|
|
|
syncNonNullNest {
|
|
|
|
promiseNonNullNest {
|
|
|
|
syncNonNullNest {
|
|
|
|
promiseNonNullNest {
|
|
|
|
promiseNonNull
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
';
|
|
|
|
|
|
|
|
$ast = Parser::parse($doc);
|
|
|
|
|
|
|
|
$expected = [
|
2018-09-01 18:07:06 +03:00
|
|
|
'data' => [
|
|
|
|
'syncNest' => null,
|
|
|
|
'promiseNest' => null,
|
|
|
|
'anotherNest' => null,
|
2016-11-26 22:48:01 +03:00
|
|
|
'anotherPromiseNest' => null,
|
|
|
|
],
|
|
|
|
'errors' => [
|
2018-08-07 21:43:23 +03:00
|
|
|
FormattedError::create($this->syncNonNullError->getMessage(), [new SourceLocation(8, 19)]),
|
|
|
|
FormattedError::create($this->syncNonNullError->getMessage(), [new SourceLocation(19, 19)]),
|
|
|
|
FormattedError::create($this->promiseNonNullError->getMessage(), [new SourceLocation(30, 19)]),
|
|
|
|
FormattedError::create($this->promiseNonNullError->getMessage(), [new SourceLocation(41, 19)]),
|
2018-09-01 18:07:06 +03:00
|
|
|
],
|
2016-11-26 22:48:01 +03:00
|
|
|
];
|
|
|
|
|
2018-09-19 18:12:09 +03:00
|
|
|
self::assertArraySubset(
|
2018-09-01 18:07:06 +03:00
|
|
|
$expected,
|
|
|
|
Executor::execute($this->schema, $ast, $this->throwingData, null, [], 'Q')->toArray()
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testNullsANullableFieldThatSynchronouslyReturnsNull() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
|
|
|
$doc = '
|
|
|
|
query Q {
|
|
|
|
sync
|
|
|
|
}
|
|
|
|
';
|
|
|
|
|
|
|
|
$ast = Parser::parse($doc);
|
|
|
|
|
|
|
|
$expected = [
|
2018-09-01 18:07:06 +03:00
|
|
|
'data' => ['sync' => null],
|
2015-07-15 20:05:46 +03:00
|
|
|
];
|
2018-09-19 18:12:09 +03:00
|
|
|
self::assertEquals(
|
2018-09-01 18:07:06 +03:00
|
|
|
$expected,
|
|
|
|
Executor::execute($this->schema, $ast, $this->nullingData, null, [], 'Q')->toArray()
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testNullsANullableFieldThatReturnsNullInAPromise() : void
|
2016-11-26 22:48:01 +03:00
|
|
|
{
|
|
|
|
$doc = '
|
|
|
|
query Q {
|
|
|
|
promise
|
|
|
|
}
|
|
|
|
';
|
|
|
|
|
|
|
|
$ast = Parser::parse($doc);
|
|
|
|
|
|
|
|
$expected = [
|
2018-09-01 18:07:06 +03:00
|
|
|
'data' => ['promise' => null],
|
2016-11-26 22:48:01 +03:00
|
|
|
];
|
|
|
|
|
2018-09-19 18:12:09 +03:00
|
|
|
self::assertArraySubset(
|
2018-09-01 18:07:06 +03:00
|
|
|
$expected,
|
|
|
|
Executor::execute($this->schema, $ast, $this->nullingData, null, [], 'Q')->toArray()
|
|
|
|
);
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testNullsASynchronouslyReturnedObjectThatContainsANonNullableFieldThatReturnsNullSynchronously() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
|
|
|
$doc = '
|
|
|
|
query Q {
|
2018-08-07 21:43:23 +03:00
|
|
|
syncNest {
|
|
|
|
syncNonNull,
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
';
|
|
|
|
|
|
|
|
$ast = Parser::parse($doc);
|
|
|
|
|
|
|
|
$expected = [
|
2018-09-01 18:07:06 +03:00
|
|
|
'data' => ['syncNest' => null],
|
2015-07-15 20:05:46 +03:00
|
|
|
'errors' => [
|
2017-07-18 16:57:30 +03:00
|
|
|
[
|
2018-08-07 21:43:23 +03:00
|
|
|
'debugMessage' => 'Cannot return null for non-nullable field DataType.syncNonNull.',
|
2018-09-01 18:07:06 +03:00
|
|
|
'locations' => [['line' => 4, 'column' => 11]],
|
|
|
|
],
|
|
|
|
],
|
2015-07-15 20:05:46 +03:00
|
|
|
];
|
2018-09-19 18:12:09 +03:00
|
|
|
self::assertArraySubset(
|
2018-09-01 18:07:06 +03:00
|
|
|
$expected,
|
|
|
|
Executor::execute($this->schema, $ast, $this->nullingData, null, [], 'Q')->toArray(true)
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testNullsASynchronouslyReturnedObjectThatContainsANonNullableFieldThatReturnsNullInAPromise() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
2016-11-26 22:48:01 +03:00
|
|
|
$doc = '
|
|
|
|
query Q {
|
2018-08-07 21:43:23 +03:00
|
|
|
syncNest {
|
|
|
|
promiseNonNull,
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
';
|
|
|
|
|
|
|
|
$ast = Parser::parse($doc);
|
|
|
|
|
|
|
|
$expected = [
|
2018-09-01 18:07:06 +03:00
|
|
|
'data' => ['syncNest' => null],
|
2016-11-26 22:48:01 +03:00
|
|
|
'errors' => [
|
2017-07-18 16:57:30 +03:00
|
|
|
[
|
2018-08-07 21:43:23 +03:00
|
|
|
'debugMessage' => 'Cannot return null for non-nullable field DataType.promiseNonNull.',
|
2018-09-01 18:07:06 +03:00
|
|
|
'locations' => [['line' => 4, 'column' => 11]],
|
2017-07-18 16:57:30 +03:00
|
|
|
],
|
2018-09-01 18:07:06 +03:00
|
|
|
],
|
2016-11-26 22:48:01 +03:00
|
|
|
];
|
2015-07-15 20:05:46 +03:00
|
|
|
|
2018-09-19 18:12:09 +03:00
|
|
|
self::assertArraySubset(
|
2017-07-18 16:57:30 +03:00
|
|
|
$expected,
|
|
|
|
Executor::execute($this->schema, $ast, $this->nullingData, null, [], 'Q')->toArray(true)
|
|
|
|
);
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testNullsAnObjectReturnedInAPromiseThatContainsANonNullableFieldThatReturnsNullSynchronously() : void
|
2016-11-26 22:48:01 +03:00
|
|
|
{
|
|
|
|
$doc = '
|
|
|
|
query Q {
|
|
|
|
promiseNest {
|
2018-08-07 21:43:23 +03:00
|
|
|
syncNonNull,
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
';
|
|
|
|
|
|
|
|
$ast = Parser::parse($doc);
|
|
|
|
|
|
|
|
$expected = [
|
2018-09-01 18:07:06 +03:00
|
|
|
'data' => ['promiseNest' => null],
|
2016-11-26 22:48:01 +03:00
|
|
|
'errors' => [
|
2017-07-18 16:57:30 +03:00
|
|
|
[
|
2018-08-07 21:43:23 +03:00
|
|
|
'debugMessage' => 'Cannot return null for non-nullable field DataType.syncNonNull.',
|
2018-09-01 18:07:06 +03:00
|
|
|
'locations' => [['line' => 4, 'column' => 11]],
|
2017-07-18 16:57:30 +03:00
|
|
|
],
|
2018-09-01 18:07:06 +03:00
|
|
|
],
|
2016-11-26 22:48:01 +03:00
|
|
|
];
|
|
|
|
|
2018-09-19 18:12:09 +03:00
|
|
|
self::assertArraySubset(
|
2017-07-18 16:57:30 +03:00
|
|
|
$expected,
|
|
|
|
Executor::execute($this->schema, $ast, $this->nullingData, null, [], 'Q')->toArray(true)
|
|
|
|
);
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testNullsAnObjectReturnedInAPromiseThatContainsANonNullableFieldThatReturnsNullInaAPromise() : void
|
2016-11-26 22:48:01 +03:00
|
|
|
{
|
|
|
|
$doc = '
|
|
|
|
query Q {
|
|
|
|
promiseNest {
|
2018-08-07 21:43:23 +03:00
|
|
|
promiseNonNull,
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
';
|
|
|
|
|
|
|
|
$ast = Parser::parse($doc);
|
|
|
|
|
|
|
|
$expected = [
|
2018-09-01 18:07:06 +03:00
|
|
|
'data' => ['promiseNest' => null],
|
2016-11-26 22:48:01 +03:00
|
|
|
'errors' => [
|
2017-07-18 16:57:30 +03:00
|
|
|
[
|
2018-08-07 21:43:23 +03:00
|
|
|
'debugMessage' => 'Cannot return null for non-nullable field DataType.promiseNonNull.',
|
2018-09-01 18:07:06 +03:00
|
|
|
'locations' => [['line' => 4, 'column' => 11]],
|
2017-07-18 16:57:30 +03:00
|
|
|
],
|
2018-09-01 18:07:06 +03:00
|
|
|
],
|
2016-11-26 22:48:01 +03:00
|
|
|
];
|
|
|
|
|
2018-09-19 18:12:09 +03:00
|
|
|
self::assertArraySubset(
|
2017-07-18 16:57:30 +03:00
|
|
|
$expected,
|
|
|
|
Executor::execute($this->schema, $ast, $this->nullingData, null, [], 'Q')->toArray(true)
|
|
|
|
);
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testNullsAComplexTreeOfNullableFieldsThatReturnNull() : void
|
2016-11-26 22:48:01 +03:00
|
|
|
{
|
2015-07-15 20:05:46 +03:00
|
|
|
$doc = '
|
|
|
|
query Q {
|
2018-08-07 21:43:23 +03:00
|
|
|
syncNest {
|
2015-07-15 20:05:46 +03:00
|
|
|
sync
|
2016-11-26 22:48:01 +03:00
|
|
|
promise
|
2018-08-07 21:43:23 +03:00
|
|
|
syncNest {
|
2015-07-15 20:05:46 +03:00
|
|
|
sync
|
2016-11-26 22:48:01 +03:00
|
|
|
promise
|
|
|
|
}
|
|
|
|
promiseNest {
|
|
|
|
sync
|
|
|
|
promise
|
|
|
|
}
|
|
|
|
}
|
|
|
|
promiseNest {
|
|
|
|
sync
|
|
|
|
promise
|
2018-08-07 21:43:23 +03:00
|
|
|
syncNest {
|
2016-11-26 22:48:01 +03:00
|
|
|
sync
|
|
|
|
promise
|
|
|
|
}
|
|
|
|
promiseNest {
|
|
|
|
sync
|
|
|
|
promise
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
';
|
|
|
|
|
|
|
|
$ast = Parser::parse($doc);
|
|
|
|
|
|
|
|
$expected = [
|
|
|
|
'data' => [
|
2018-09-01 18:07:06 +03:00
|
|
|
'syncNest' => [
|
|
|
|
'sync' => null,
|
|
|
|
'promise' => null,
|
|
|
|
'syncNest' => [
|
|
|
|
'sync' => null,
|
2016-11-26 22:48:01 +03:00
|
|
|
'promise' => null,
|
2015-07-15 20:05:46 +03:00
|
|
|
],
|
2016-11-26 22:48:01 +03:00
|
|
|
'promiseNest' => [
|
2018-09-01 18:07:06 +03:00
|
|
|
'sync' => null,
|
2016-11-26 22:48:01 +03:00
|
|
|
'promise' => null,
|
2018-09-01 18:07:06 +03:00
|
|
|
],
|
2015-07-15 20:05:46 +03:00
|
|
|
],
|
2016-11-26 22:48:01 +03:00
|
|
|
'promiseNest' => [
|
2018-09-01 18:07:06 +03:00
|
|
|
'sync' => null,
|
|
|
|
'promise' => null,
|
|
|
|
'syncNest' => [
|
|
|
|
'sync' => null,
|
2016-11-26 22:48:01 +03:00
|
|
|
'promise' => null,
|
|
|
|
],
|
|
|
|
'promiseNest' => [
|
2018-09-01 18:07:06 +03:00
|
|
|
'sync' => null,
|
2016-11-26 22:48:01 +03:00
|
|
|
'promise' => null,
|
2018-09-01 18:07:06 +03:00
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
2015-07-15 20:05:46 +03:00
|
|
|
];
|
2016-11-26 22:48:01 +03:00
|
|
|
|
2016-12-03 00:11:14 +03:00
|
|
|
$actual = Executor::execute($this->schema, $ast, $this->nullingData, null, [], 'Q')->toArray();
|
2018-09-19 18:12:09 +03:00
|
|
|
self::assertEquals($expected, $actual);
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testNullsTheFirstNullableObjectAfterAFieldReturnsNullInALongChainOfFieldsThatAreNonNull() : void
|
2016-11-26 22:48:01 +03:00
|
|
|
{
|
|
|
|
$doc = '
|
|
|
|
query Q {
|
2018-08-07 21:43:23 +03:00
|
|
|
syncNest {
|
|
|
|
syncNonNullNest {
|
|
|
|
promiseNonNullNest {
|
|
|
|
syncNonNullNest {
|
|
|
|
promiseNonNullNest {
|
|
|
|
syncNonNull
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
promiseNest {
|
2018-08-07 21:43:23 +03:00
|
|
|
syncNonNullNest {
|
|
|
|
promiseNonNullNest {
|
|
|
|
syncNonNullNest {
|
|
|
|
promiseNonNullNest {
|
|
|
|
syncNonNull
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-08-07 21:43:23 +03:00
|
|
|
anotherNest: syncNest {
|
|
|
|
syncNonNullNest {
|
|
|
|
promiseNonNullNest {
|
|
|
|
syncNonNullNest {
|
|
|
|
promiseNonNullNest {
|
|
|
|
promiseNonNull
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
anotherPromiseNest: promiseNest {
|
2018-08-07 21:43:23 +03:00
|
|
|
syncNonNullNest {
|
|
|
|
promiseNonNullNest {
|
|
|
|
syncNonNullNest {
|
|
|
|
promiseNonNullNest {
|
|
|
|
promiseNonNull
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
';
|
|
|
|
|
|
|
|
$ast = Parser::parse($doc);
|
|
|
|
|
|
|
|
$expected = [
|
2018-09-01 18:07:06 +03:00
|
|
|
'data' => [
|
|
|
|
'syncNest' => null,
|
|
|
|
'promiseNest' => null,
|
|
|
|
'anotherNest' => null,
|
2016-11-26 22:48:01 +03:00
|
|
|
'anotherPromiseNest' => null,
|
|
|
|
],
|
|
|
|
'errors' => [
|
2018-09-01 18:07:06 +03:00
|
|
|
['debugMessage' => 'Cannot return null for non-nullable field DataType.syncNonNull.', 'locations' => [['line' => 8, 'column' => 19]]],
|
|
|
|
['debugMessage' => 'Cannot return null for non-nullable field DataType.syncNonNull.', 'locations' => [['line' => 19, 'column' => 19]]],
|
|
|
|
['debugMessage' => 'Cannot return null for non-nullable field DataType.promiseNonNull.', 'locations' => [['line' => 30, 'column' => 19]]],
|
|
|
|
['debugMessage' => 'Cannot return null for non-nullable field DataType.promiseNonNull.', 'locations' => [['line' => 41, 'column' => 19]]],
|
|
|
|
],
|
2016-11-26 22:48:01 +03:00
|
|
|
];
|
|
|
|
|
2018-09-19 18:12:09 +03:00
|
|
|
self::assertArraySubset(
|
2017-07-18 16:57:30 +03:00
|
|
|
$expected,
|
|
|
|
Executor::execute($this->schema, $ast, $this->nullingData, null, [], 'Q')->toArray(true)
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2016-12-03 00:11:14 +03:00
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('nulls the top level if sync non-nullable field throws')
|
2016-12-03 00:11:14 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testNullsTheTopLevelIfSyncNonNullableFieldThrows() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
|
|
|
$doc = '
|
2018-08-07 21:43:23 +03:00
|
|
|
query Q { syncNonNull }
|
2015-07-15 20:05:46 +03:00
|
|
|
';
|
|
|
|
|
|
|
|
$expected = [
|
|
|
|
'errors' => [
|
2018-09-01 18:07:06 +03:00
|
|
|
FormattedError::create($this->syncNonNullError->getMessage(), [new SourceLocation(2, 17)]),
|
|
|
|
],
|
2015-07-15 20:05:46 +03:00
|
|
|
];
|
2018-09-01 18:07:06 +03:00
|
|
|
$actual = Executor::execute($this->schema, Parser::parse($doc), $this->throwingData)->toArray();
|
2018-09-19 18:12:09 +03:00
|
|
|
self::assertArraySubset($expected, $actual);
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
|
|
|
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testNullsTheTopLevelIfAsyncNonNullableFieldErrors() : void
|
2016-11-26 22:48:01 +03:00
|
|
|
{
|
|
|
|
$doc = '
|
2018-08-07 21:43:23 +03:00
|
|
|
query Q { promiseNonNull }
|
2016-11-26 22:48:01 +03:00
|
|
|
';
|
|
|
|
|
|
|
|
$ast = Parser::parse($doc);
|
|
|
|
|
|
|
|
$expected = [
|
|
|
|
'errors' => [
|
2018-08-07 21:43:23 +03:00
|
|
|
FormattedError::create($this->promiseNonNullError->getMessage(), [new SourceLocation(2, 17)]),
|
2018-09-01 18:07:06 +03:00
|
|
|
],
|
2016-11-26 22:48:01 +03:00
|
|
|
];
|
|
|
|
|
2018-09-19 18:12:09 +03:00
|
|
|
self::assertArraySubset(
|
2018-09-01 18:07:06 +03:00
|
|
|
$expected,
|
|
|
|
Executor::execute($this->schema, $ast, $this->throwingData, null, [], 'Q')->toArray()
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testNullsTheTopLevelIfSyncNonNullableFieldReturnsNull() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
|
|
|
// nulls the top level if sync non-nullable field returns null
|
|
|
|
$doc = '
|
2018-08-07 21:43:23 +03:00
|
|
|
query Q { syncNonNull }
|
2015-07-15 20:05:46 +03:00
|
|
|
';
|
|
|
|
|
|
|
|
$expected = [
|
|
|
|
'errors' => [
|
2017-07-18 16:57:30 +03:00
|
|
|
[
|
2018-08-07 21:43:23 +03:00
|
|
|
'debugMessage' => 'Cannot return null for non-nullable field DataType.syncNonNull.',
|
2018-09-01 18:07:06 +03:00
|
|
|
'locations' => [['line' => 2, 'column' => 17]],
|
2017-07-18 16:57:30 +03:00
|
|
|
],
|
2018-09-01 18:07:06 +03:00
|
|
|
],
|
2015-07-15 20:05:46 +03:00
|
|
|
];
|
2018-09-19 18:12:09 +03:00
|
|
|
self::assertArraySubset(
|
2017-07-18 16:57:30 +03:00
|
|
|
$expected,
|
|
|
|
Executor::execute($this->schema, Parser::parse($doc), $this->nullingData)->toArray(true)
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
2016-11-26 22:48:01 +03:00
|
|
|
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testNullsTheTopLevelIfAsyncNonNullableFieldResolvesNull() : void
|
2016-11-26 22:48:01 +03:00
|
|
|
{
|
|
|
|
$doc = '
|
2018-08-07 21:43:23 +03:00
|
|
|
query Q { promiseNonNull }
|
2016-11-26 22:48:01 +03:00
|
|
|
';
|
|
|
|
|
|
|
|
$ast = Parser::parse($doc);
|
|
|
|
|
|
|
|
$expected = [
|
|
|
|
'errors' => [
|
2017-07-18 16:57:30 +03:00
|
|
|
[
|
2018-08-07 21:43:23 +03:00
|
|
|
'debugMessage' => 'Cannot return null for non-nullable field DataType.promiseNonNull.',
|
2018-09-01 18:07:06 +03:00
|
|
|
'locations' => [['line' => 2, 'column' => 17]],
|
2017-07-18 16:57:30 +03:00
|
|
|
],
|
2018-09-01 18:07:06 +03:00
|
|
|
],
|
2016-11-26 22:48:01 +03:00
|
|
|
];
|
|
|
|
|
2018-09-19 18:12:09 +03:00
|
|
|
self::assertArraySubset(
|
2017-07-18 16:57:30 +03:00
|
|
|
$expected,
|
|
|
|
Executor::execute($this->schema, $ast, $this->nullingData, null, [], 'Q')->toArray(true)
|
|
|
|
);
|
2016-11-26 22:48:01 +03:00
|
|
|
}
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|