Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Testing of "Implement Apollo Federation v2" #2

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion implementations/php/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
39 changes: 28 additions & 11 deletions implementations/php/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion implementations/php/src/Type/DeprecatedProductType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) ],
Expand Down
4 changes: 3 additions & 1 deletion implementations/php/src/Type/ProductResearchType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() ]
Expand Down
6 changes: 5 additions & 1 deletion implementations/php/src/Type/ProductType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() ],
Expand Down
4 changes: 3 additions & 1 deletion implementations/php/src/Type/UserType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ public function __construct()
{
parent::__construct([
'name' => 'User',
'keyFields' => [ 'email' ],
'keys' => [
[ 'fields' => 'email', 'resolvable' => false ]
],
'fields' => [
'averageProductsCreatedPerYear' => [
'type' => Types::int(),
Expand Down
26 changes: 13 additions & 13 deletions implementations/php/src/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@

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);

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);
}