-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update apollo-federation-php with latest schema changes (#346)
- Loading branch information
1 parent
452d03f
commit 98c28f9
Showing
16 changed files
with
395 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace GraphQL\Compatibility\Data; | ||
|
||
use GraphQL\Utils\Utils; | ||
|
||
class CaseStudy | ||
{ | ||
public string $caseNumber; | ||
|
||
public string $description; | ||
|
||
public function __construct(array $data) | ||
{ | ||
Utils::assign($this, $data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace GraphQL\Compatibility\Data; | ||
|
||
use GraphQL\Utils\Utils; | ||
|
||
class DeprecatedProduct | ||
{ | ||
public string $sku; | ||
|
||
public string $package; | ||
|
||
public string $reason; | ||
|
||
public function __construct(array $data) | ||
{ | ||
Utils::assign($this, $data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace GraphQL\Compatibility\Data; | ||
|
||
use GraphQL\Utils\Utils; | ||
|
||
class ProductResearch | ||
{ | ||
public CaseStudy $study; | ||
|
||
public string $outcome; | ||
|
||
public function __construct(array $data) | ||
{ | ||
Utils::assign($this, $data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace GraphQL\Compatibility\Data; | ||
|
||
use GraphQL\Utils\Utils; | ||
|
||
class User | ||
{ | ||
public string $email; | ||
|
||
public string $name; | ||
|
||
public int $totalProductsCreated; | ||
|
||
public int $yearsOfEmployment; | ||
|
||
public function __construct(array $data) | ||
{ | ||
Utils::assign($this, $data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace GraphQL\Compatibility\Type; | ||
|
||
use GraphQL\Compatibility\Types; | ||
use GraphQL\Type\Definition\ObjectType; | ||
|
||
class CaseStudyType extends ObjectType { | ||
public function __construct() | ||
{ | ||
parent::__construct([ | ||
'name' => 'CaseStudy', | ||
'fields' => [ | ||
'caseNumber' => [ 'type' => Types::nonNull(Types::id()) ], | ||
'description' => [ 'type' => Types::string() ] | ||
] | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace GraphQL\Compatibility\Type; | ||
|
||
use GraphQL\Compatibility\Types; | ||
use GraphQL\Compatibility\Data\DeprecatedProduct; | ||
use GraphQL\Compatibility\Data\DataSource; | ||
|
||
use Apollo\Federation\Types\EntityObjectType; | ||
|
||
class DeprecatedProductType extends EntityObjectType { | ||
public function __construct() | ||
{ | ||
parent::__construct([ | ||
'name' => 'DeprecatedProduct', | ||
'keyFields' => ['sku package'], | ||
'fields' => [ | ||
'sku' => [ 'type' => Types::nonNull(Types::string()) ], | ||
'package' => [ 'type' => Types::nonNull(Types::string()) ], | ||
'reason' => [ 'type' => Types::string() ], | ||
'createdBy' => [ | ||
'type' => Types::user(), | ||
'provides' => 'totalProductsCreated', | ||
'resolve' => static fn (): array => [ | ||
'email' => 'support@apollographql.com', | ||
'totalProductsCreated' => 1337, | ||
] | ||
], | ||
], | ||
'__resolveReference' => function ($ref) { | ||
$sku = $ref['sku']; | ||
$package = $ref['package']; | ||
|
||
if ($sku !== null && $package !== null) { | ||
return DataSource::findDeprecatedProductBySkuAndPackage($sku, $package); | ||
} | ||
}, | ||
'isTypeOf' => function ($value) { | ||
if ($value instanceof DeprecatedProduct) { | ||
return true; | ||
} | ||
}, | ||
]); | ||
} | ||
|
||
static function getVariation(string $variation): array { | ||
return [ 'id' => $variation ]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.