diff --git a/implementations/php/composer.json b/implementations/php/composer.json index 7593bca1f..fb6836990 100644 --- a/implementations/php/composer.json +++ b/implementations/php/composer.json @@ -3,8 +3,14 @@ "type": "project", "require": { "webonyx/graphql-php": "^14.11", - "skillshare/apollo-federation-php": "^1.6" + "skillshare/apollo-federation-php": "dev-implement_v2" }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/Aeliot-Tm/apollo-federation-php" + } + ], "autoload": { "psr-4": { "GraphQL\\Compatibility\\": "src/" diff --git a/implementations/php/composer.lock b/implementations/php/composer.lock index 85cb4e147..fedbeb922 100644 --- a/implementations/php/composer.lock +++ b/implementations/php/composer.lock @@ -4,23 +4,24 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "57d55804cbdc320f24d6bc24b7a3e347", + "content-hash": "9d77f8a1830d0144a841687779cee486", "packages": [ { "name": "skillshare/apollo-federation-php", - "version": "v1.6", + "version": "dev-implement_v2", "source": { "type": "git", - "url": "https://github.com/Skillshare/apollo-federation-php.git", - "reference": "4f958ddb683c1fceb1d162f58a5dc2957e26fe5d" + "url": "https://github.com/Aeliot-Tm/apollo-federation-php.git", + "reference": "b81878710f0160f96c97ed1f6b8e5ecaa69acd52" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Skillshare/apollo-federation-php/zipball/4f958ddb683c1fceb1d162f58a5dc2957e26fe5d", - "reference": "4f958ddb683c1fceb1d162f58a5dc2957e26fe5d", + "url": "https://api.github.com/repos/Aeliot-Tm/apollo-federation-php/zipball/b81878710f0160f96c97ed1f6b8e5ecaa69acd52", + "reference": "b81878710f0160f96c97ed1f6b8e5ecaa69acd52", "shasum": "" }, "require": { + "ext-json": "*", "php": "^7.1||^8.0", "webonyx/graphql-php": "^0.13.8 || ^14.0" }, @@ -36,16 +37,30 @@ "Apollo\\Federation\\": "src/" } }, - "notification-url": "https://packagist.org/downloads/", + "autoload-dev": { + "psr-4": { + "Apollo\\Federation\\Tests\\": "test/" + } + }, + "scripts": { + "test": [ + "phpunit" + ], + "sync": [ + "yarn install && composer update" + ], + "commit": [ + "yarn commit" + ] + }, "license": [ "MIT" ], "description": "A PHP port of the Apollo Federation specification.", "support": { - "issues": "https://github.com/Skillshare/apollo-federation-php/issues", - "source": "https://github.com/Skillshare/apollo-federation-php/tree/v1.6" + "source": "https://github.com/Aeliot-Tm/apollo-federation-php/tree/implement_v2" }, - "time": "2022-08-16T19:05:32+00:00" + "time": "2023-02-09T18:39:48+00:00" }, { "name": "webonyx/graphql-php", @@ -117,7 +132,9 @@ "packages-dev": [], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "skillshare/apollo-federation-php": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": [], diff --git a/implementations/php/src/Type/DeprecatedProductType.php b/implementations/php/src/Type/DeprecatedProductType.php index 9f7bad3b4..27a824341 100644 --- a/implementations/php/src/Type/DeprecatedProductType.php +++ b/implementations/php/src/Type/DeprecatedProductType.php @@ -15,7 +15,9 @@ public function __construct() { parent::__construct([ 'name' => 'DeprecatedProduct', - 'keyFields' => ['sku package'], + 'keys' => [ + ['fields' => 'sku package'], + ], 'fields' => [ 'sku' => [ 'type' => Types::nonNull(Types::string()) ], 'package' => [ 'type' => Types::nonNull(Types::string()) ], diff --git a/implementations/php/src/Type/ProductResearchType.php b/implementations/php/src/Type/ProductResearchType.php index af6d3d638..3c84abbc2 100644 --- a/implementations/php/src/Type/ProductResearchType.php +++ b/implementations/php/src/Type/ProductResearchType.php @@ -15,7 +15,9 @@ public function __construct() { parent::__construct([ 'name' => 'ProductResearch', - 'keyFields' => ['study { caseNumber }'], + 'keys' => [ + ['fields' => 'study { caseNumber }'], + ], 'fields' => [ 'study' => ['type' => Types::nonNull(Types::caseStudy())], 'outcome' => [ 'type' => Types::string() ] diff --git a/implementations/php/src/Type/ProductType.php b/implementations/php/src/Type/ProductType.php index 1455b23ec..b57c3fc4d 100644 --- a/implementations/php/src/Type/ProductType.php +++ b/implementations/php/src/Type/ProductType.php @@ -15,7 +15,11 @@ public function __construct() { parent::__construct([ 'name' => 'Product', - 'keyFields' => ['id', 'sku package', 'sku variation { id }'], + 'keys' => [ + ['fields' => 'id'], + ['fields' => 'sku package'], + ['fields' => 'sku variation { id }'], + ], 'fields' => [ 'id' => [ 'type' => Types::nonNull(Types::id()) ], 'sku' => [ 'type' => Types::string() ], diff --git a/implementations/php/src/Type/UserType.php b/implementations/php/src/Type/UserType.php index 44f7a1210..b640947cf 100644 --- a/implementations/php/src/Type/UserType.php +++ b/implementations/php/src/Type/UserType.php @@ -14,7 +14,9 @@ public function __construct() { parent::__construct([ 'name' => 'User', - 'keyFields' => [ 'email' ], + 'keys' => [ + [ 'fields' => 'email', 'resolvable' => false ] + ], 'fields' => [ 'averageProductsCreatedPerYear' => [ 'type' => Types::int(), diff --git a/implementations/php/src/server.php b/implementations/php/src/server.php index 1ea787a84..22175e8dd 100644 --- a/implementations/php/src/server.php +++ b/implementations/php/src/server.php @@ -6,17 +6,12 @@ require_once __DIR__ . '/../vendor/autoload.php'; -use Closure; -use Exception; +use Apollo\Federation\Enum\DirectiveEnum; +use Apollo\Federation\SchemaBuilder; -use GraphQL\Server\StandardServer; -use GraphQL\Type\Definition\Type; - -use GraphQL\Compatibility\Types; -use GraphQL\Compatibility\Type\QueryType; use GraphQL\Compatibility\Data\DataSource; - -use Apollo\Federation\FederatedSchema; +use GraphQL\Compatibility\Type\QueryType; +use GraphQL\Server\StandardServer; // turn off deprecation notices error_reporting(E_ALL ^ E_DEPRECATED); @@ -24,15 +19,20 @@ try { DataSource::init(); - $schema = new FederatedSchema([ - 'query' => new QueryType(), - ]); + $schema = (new SchemaBuilder())->build( + [ + 'query' => new QueryType(), + ], + [ + 'directives' => DirectiveEnum::getAll(), + ], + ); $server = new StandardServer([ 'schema' => $schema, ]); $server->handleRequest(); -} catch (Throwable $error) { +} catch (\Throwable $error) { StandardServer::send500Error($error); }