public function setUp()
{
$this->syncError = new \Exception('sync');
$this->nonNullSyncError = new \Exception('nonNullSync');
$this->promiseError = new \Exception('promise');
$this->nonNullPromiseError = new \Exception('nonNullPromise');
$this->throwingData = ['sync' => function () {
throw $this->syncError;
}, 'nonNullSync' => function () {
throw $this->nonNullSyncError;
}, 'promise' => function () {
return new Promise(function () {
throw $this->promiseError;
});
}, 'nonNullPromise' => function () {
return new Promise(function () {
throw $this->nonNullPromiseError;
});
}, 'nest' => function () {
return $this->throwingData;
}, 'nonNullNest' => function () {
return $this->throwingData;
}, 'promiseNest' => function () {
return new Promise(function (callable $resolve) {
$resolve($this->throwingData);
});
}, 'nonNullPromiseNest' => function () {
return new Promise(function (callable $resolve) {
$resolve($this->throwingData);
});
}];
$this->nullingData = ['sync' => function () {
return null;
}, 'nonNullSync' => function () {
return null;
}, 'promise' => function () {
return new Promise(function (callable $resolve) {
return $resolve(null);
});
}, 'nonNullPromise' => function () {
return new Promise(function (callable $resolve) {
return $resolve(null);
});
}, 'nest' => function () {
return $this->nullingData;
}, 'nonNullNest' => function () {
return $this->nullingData;
}, 'promiseNest' => function () {
return new Promise(function (callable $resolve) {
$resolve($this->nullingData);
});
}, 'nonNullPromiseNest' => function () {
return new Promise(function (callable $resolve) {
$resolve($this->nullingData);
});
}];
$dataType = new ObjectType(['name' => 'DataType', 'fields' => function () use(&$dataType) {
return ['sync' => ['type' => Type::string()], 'nonNullSync' => ['type' => Type::nonNull(Type::string())], 'promise' => Type::string(), 'nonNullPromise' => Type::nonNull(Type::string()), 'nest' => $dataType, 'nonNullNest' => Type::nonNull($dataType), 'promiseNest' => $dataType, 'nonNullPromiseNest' => Type::nonNull($dataType)];
}]);
$this->schema = new Schema(['query' => $dataType]);
}