diff --git a/app/common.php b/app/common.php index 025172d..b1a76e1 100644 --- a/app/common.php +++ b/app/common.php @@ -5,7 +5,7 @@ use GraphQL\Type\Definition\NonNull; use GraphQL\Type\Definition\ObjectType; use GraphQL\Type\Definition\Type; -use GraphQL\Schema; +use GraphQL\Type\Schema; function renderMessage($query, $data, $calls, $callsIds) { @@ -89,14 +89,24 @@ function createSchema(callable $friendsResolver, callable $characterResolver) function executeQueries(Schema $schema, &$calls, &$callsIds, PromiseAdapter $promiseAdapter = null, callable $beforeExecute = null, callable $afterExecute = null) { - GraphQL::setPromiseAdapter($promiseAdapter); - foreach (getQueries() as $query) { $calls = 0; $callsIds = []; if (null !== $beforeExecute) { $beforeExecute(); } - $result = GraphQL::execute($schema, $query); + if (null === $promiseAdapter) { + $result = GraphQL::executeQuery($schema, $query); + } else { + $promise = GraphQL::promiseToExecute($promiseAdapter, $schema, $query); + if ($promiseAdapter instanceof \GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter) { + $result = $promiseAdapter->wait($promise)->toArray(); + } else { + $result = $promise->then(static function ($r) { + return $r->toArray(); + }); + } + } + if (null !== $afterExecute) { $result = $afterExecute($result); } renderMessage($query, $result, $calls, $callsIds); diff --git a/composer.json b/composer.json index d7a813f..793ab91 100644 --- a/composer.json +++ b/composer.json @@ -4,8 +4,8 @@ "minimum-stability": "dev", "require": { "overblog/dataloader-php": "dev-master", - "react/promise": "^2.4", - "webonyx/graphql-php": "^0.9.0" + "react/promise": "2.7.1", + "webonyx/graphql-php": "^0.13" }, "autoload": { "files": [ diff --git a/composer.lock b/composer.lock index a34602e..4d7a6f5 100644 --- a/composer.lock +++ b/composer.lock @@ -1,11 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "hash": "e072609ed78c87692be64c24d8fdbc5f", - "content-hash": "b5d803e2dcec4859c9969baf3a8bcf2b", + "content-hash": "f7177b3e7c9ce95c4bcf678d0126237e", "packages": [ { "name": "overblog/dataloader-php", @@ -13,13 +12,19 @@ "source": { "type": "git", "url": "https://github.com/overblog/dataloader-php.git", - "reference": "797c49350dd9a69b50278103c0f55ae1371fe2ae" + "reference": "9828eb526faf54266f633928d2853d6bdd085c44" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/overblog/dataloader-php/zipball/797c49350dd9a69b50278103c0f55ae1371fe2ae", - "reference": "797c49350dd9a69b50278103c0f55ae1371fe2ae", - "shasum": "" + "url": "https://api.github.com/repos/overblog/dataloader-php/zipball/9828eb526faf54266f633928d2853d6bdd085c44", + "reference": "9828eb526faf54266f633928d2853d6bdd085c44", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "php": "^5.5|^7.0" @@ -31,7 +36,7 @@ "guzzlehttp/promises": "^1.3.0", "phpunit/phpunit": "^4.1|^5.1", "react/promise": "^2.5.0", - "webonyx/graphql-php": "^0.9.0" + "webonyx/graphql-php": "^0.11.0" }, "suggest": { "guzzlehttp/promises": "To use with Guzzle promise", @@ -41,7 +46,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "0.4-dev" + "dev-master": "0.5-dev" } }, "autoload": { @@ -60,25 +65,34 @@ "caching", "dataLoader" ], - "time": "2017-02-06 16:41:33" + "time": "2018-12-15T17:27:06+00:00" }, { "name": "react/promise", - "version": "2.x-dev", + "version": "v2.7.1", "source": { "type": "git", "url": "https://github.com/reactphp/promise.git", - "reference": "2760f3898b7e931aa71153852dcd48a75c9b95db" + "reference": "31ffa96f8d2ed0341a57848cbb84d88b89dd664d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/reactphp/promise/zipball/2760f3898b7e931aa71153852dcd48a75c9b95db", - "reference": "2760f3898b7e931aa71153852dcd48a75c9b95db", - "shasum": "" + "url": "https://api.github.com/repos/reactphp/promise/zipball/31ffa96f8d2ed0341a57848cbb84d88b89dd664d", + "reference": "31ffa96f8d2ed0341a57848cbb84d88b89dd664d", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "php": ">=5.4.0" }, + "require-dev": { + "phpunit/phpunit": "~4.8" + }, "type": "library", "autoload": { "psr-4": { @@ -103,44 +117,57 @@ "promise", "promises" ], - "time": "2016-12-22 14:09:01" + "time": "2019-01-07T21:25:54+00:00" }, { "name": "webonyx/graphql-php", - "version": "v0.9.2", + "version": "0.13.x-dev", "source": { "type": "git", "url": "https://github.com/webonyx/graphql-php.git", - "reference": "c2f0749d8e9ed0edeaf7c9a206e28b1c5c45fe80" + "reference": "6829ae58f4c59121df1f86915fb9917a2ec595e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webonyx/graphql-php/zipball/c2f0749d8e9ed0edeaf7c9a206e28b1c5c45fe80", - "reference": "c2f0749d8e9ed0edeaf7c9a206e28b1c5c45fe80", - "shasum": "" + "url": "https://api.github.com/repos/webonyx/graphql-php/zipball/6829ae58f4c59121df1f86915fb9917a2ec595e8", + "reference": "6829ae58f4c59121df1f86915fb9917a2ec595e8", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { + "ext-json": "*", "ext-mbstring": "*", - "php": ">=5.4,<8.0-DEV" + "php": "^7.1||^8.0" }, "require-dev": { - "phpunit/phpunit": "^4.8" + "doctrine/coding-standard": "^6.0", + "phpbench/phpbench": "^0.14.0", + "phpstan/phpstan": "^0.11.4", + "phpstan/phpstan-phpunit": "^0.11.0", + "phpstan/phpstan-strict-rules": "^0.11.0", + "phpunit/phpcov": "^5.0", + "phpunit/phpunit": "^7.2", + "psr/http-message": "^1.0", + "react/promise": "2.*" }, "suggest": { - "react/promise": "To use ReactPHP promise adapter" + "psr/http-message": "To use standard GraphQL server", + "react/promise": "To leverage async resolving on React PHP platform" }, "type": "library", "autoload": { - "files": [ - "src/deprecated.php" - ], "psr-4": { "GraphQL\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD" + "MIT" ], "description": "A PHP port of GraphQL reference implementation", "homepage": "https://github.com/webonyx/graphql-php", @@ -148,7 +175,7 @@ "api", "graphql" ], - "time": "2017-02-07 06:01:36" + "time": "2019-08-25T10:32:47+00:00" } ], "packages-dev": [],