setPromiseAdapter() public static method

public static setPromiseAdapter ( GraphQL\Executor\Promise\PromiseAdapter $promiseAdapter = null )
$promiseAdapter GraphQL\Executor\Promise\PromiseAdapter
Ejemplo n.º 1
0
 public function testCorrectFieldOrderingDespiteExecutionOrder()
 {
     Executor::setPromiseAdapter(new ReactPromiseAdapter());
     $doc = '{
   a,
   b,
   c,
   d,
   e
 }';
     $data = ['a' => function () {
         return 'a';
     }, 'b' => function () {
         return new Promise(function (callable $resolve) {
             return $resolve('b');
         });
     }, 'c' => function () {
         return 'c';
     }, 'd' => function () {
         return new Promise(function (callable $resolve) {
             return $resolve('d');
         });
     }, 'e' => function () {
         return 'e';
     }];
     $ast = Parser::parse($doc);
     $queryType = new ObjectType(['name' => 'DeepDataType', 'fields' => ['a' => ['type' => Type::string()], 'b' => ['type' => Type::string()], 'c' => ['type' => Type::string()], 'd' => ['type' => Type::string()], 'e' => ['type' => Type::string()]]]);
     $schema = new Schema(['query' => $queryType]);
     $expected = ['data' => ['a' => 'a', 'b' => 'b', 'c' => 'c', 'd' => 'd', 'e' => 'e']];
     $this->assertEquals($expected, self::awaitPromise(Executor::execute($schema, $ast, $data)));
 }
Ejemplo n.º 2
0
 public static function tearDownAfterClass()
 {
     Executor::setPromiseAdapter(null);
 }
Ejemplo n.º 3
0
 public function testNullsTheTopLevelIfAsyncNonNullableFieldResolvesNull()
 {
     $doc = '
   query Q { nonNullPromise }
 ';
     $ast = Parser::parse($doc);
     $expected = ['data' => null, 'errors' => [FormattedError::create('Cannot return null for non-nullable field DataType.nonNullPromise.', [new SourceLocation(2, 17)])]];
     Executor::setPromiseAdapter(new ReactPromiseAdapter());
     $this->assertArraySubsetPromise($expected, Executor::execute($this->schema, $ast, $this->nullingData, null, [], 'Q'));
 }
Ejemplo n.º 4
0
 /**
  * @param PromiseAdapter|null $promiseAdapter
  */
 public static function setPromiseAdapter(PromiseAdapter $promiseAdapter = null)
 {
     Executor::setPromiseAdapter($promiseAdapter);
 }