generated from spawnia/php-package-template
-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
32 changed files
with
1,219 additions
and
59 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
71 changes: 71 additions & 0 deletions
71
examples/polymorphic/expected/Operations/NodeWithFragments.php
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,71 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Spawnia\Sailor\Polymorphic\Operations; | ||
|
||
/** | ||
* @extends \Spawnia\Sailor\Operation<\Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\NodeWithFragmentsResult> | ||
*/ | ||
class NodeWithFragments extends \Spawnia\Sailor\Operation | ||
{ | ||
/** | ||
* @param string $id | ||
*/ | ||
public static function execute($id): NodeWithFragments\NodeWithFragmentsResult | ||
{ | ||
return self::executeOperation( | ||
$id, | ||
); | ||
} | ||
|
||
protected static function converters(): array | ||
{ | ||
static $converters; | ||
|
||
return $converters ??= [ | ||
['id', new \Spawnia\Sailor\Convert\NonNullConverter(new \Spawnia\Sailor\Convert\IDConverter)], | ||
]; | ||
} | ||
|
||
public static function document(): string | ||
{ | ||
return /* @lang GraphQL */ 'query NodeWithFragments($id: ID!) { | ||
__typename | ||
node(id: $id) { | ||
__typename | ||
node { | ||
__typename | ||
node { | ||
__typename | ||
id | ||
... on User { | ||
id | ||
} | ||
} | ||
} | ||
... on Task { | ||
done | ||
node { | ||
__typename | ||
node { | ||
__typename | ||
... on User { | ||
name | ||
} | ||
} | ||
} | ||
} | ||
... on Post { | ||
id | ||
title | ||
} | ||
} | ||
}'; | ||
} | ||
|
||
public static function endpoint(): string | ||
{ | ||
return 'polymorphic'; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
examples/polymorphic/expected/Operations/NodeWithFragments/Node/Node/Node/Post.php
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,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node\Node; | ||
|
||
/** | ||
* @property string $id | ||
* @property string $__typename | ||
*/ | ||
class Post extends \Spawnia\Sailor\ObjectLike | ||
{ | ||
/** | ||
* @param string $id | ||
*/ | ||
public static function make($id): self | ||
{ | ||
$instance = new self; | ||
|
||
if ($id !== self::UNDEFINED) { | ||
$instance->id = $id; | ||
} | ||
$instance->__typename = 'Node'; | ||
|
||
return $instance; | ||
} | ||
|
||
protected function converters(): array | ||
{ | ||
static $converters; | ||
|
||
return $converters ??= [ | ||
'id' => new \Spawnia\Sailor\Convert\NonNullConverter(new \Spawnia\Sailor\Convert\IDConverter), | ||
'__typename' => new \Spawnia\Sailor\Convert\NonNullConverter(new \Spawnia\Sailor\Convert\StringConverter), | ||
]; | ||
} | ||
|
||
public static function endpoint(): string | ||
{ | ||
return 'polymorphic'; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
examples/polymorphic/expected/Operations/NodeWithFragments/Node/Node/Node/Task.php
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,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node\Node; | ||
|
||
/** | ||
* @property string $id | ||
* @property string $__typename | ||
*/ | ||
class Task extends \Spawnia\Sailor\ObjectLike | ||
{ | ||
/** | ||
* @param string $id | ||
*/ | ||
public static function make($id): self | ||
{ | ||
$instance = new self; | ||
|
||
if ($id !== self::UNDEFINED) { | ||
$instance->id = $id; | ||
} | ||
$instance->__typename = 'Node'; | ||
|
||
return $instance; | ||
} | ||
|
||
protected function converters(): array | ||
{ | ||
static $converters; | ||
|
||
return $converters ??= [ | ||
'id' => new \Spawnia\Sailor\Convert\NonNullConverter(new \Spawnia\Sailor\Convert\IDConverter), | ||
'__typename' => new \Spawnia\Sailor\Convert\NonNullConverter(new \Spawnia\Sailor\Convert\StringConverter), | ||
]; | ||
} | ||
|
||
public static function endpoint(): string | ||
{ | ||
return 'polymorphic'; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
examples/polymorphic/expected/Operations/NodeWithFragments/Node/Node/Node/User.php
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,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node\Node; | ||
|
||
/** | ||
* @property string $id | ||
* @property string $__typename | ||
* @property string|null $name | ||
*/ | ||
class User extends \Spawnia\Sailor\ObjectLike | ||
{ | ||
/** | ||
* @param string $id | ||
* @param string|null $name | ||
*/ | ||
public static function make( | ||
$id, | ||
$name = 'Special default value that allows Sailor to differentiate between explicitly passing null and not passing a value at all.' | ||
): self { | ||
$instance = new self; | ||
|
||
if ($id !== self::UNDEFINED) { | ||
$instance->id = $id; | ||
} | ||
$instance->__typename = 'Node'; | ||
if ($name !== self::UNDEFINED) { | ||
$instance->name = $name; | ||
} | ||
|
||
return $instance; | ||
} | ||
|
||
protected function converters(): array | ||
{ | ||
static $converters; | ||
|
||
return $converters ??= [ | ||
'id' => new \Spawnia\Sailor\Convert\NonNullConverter(new \Spawnia\Sailor\Convert\IDConverter), | ||
'__typename' => new \Spawnia\Sailor\Convert\NonNullConverter(new \Spawnia\Sailor\Convert\StringConverter), | ||
'name' => new \Spawnia\Sailor\Convert\NullConverter(new \Spawnia\Sailor\Convert\StringConverter), | ||
]; | ||
} | ||
|
||
public static function endpoint(): string | ||
{ | ||
return 'polymorphic'; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
examples/polymorphic/expected/Operations/NodeWithFragments/Node/Node/Post.php
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,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node; | ||
|
||
/** | ||
* @property string $__typename | ||
* @property \Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node\Node\User|\Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node\Node\Task|\Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node\Node\Post|null $node | ||
*/ | ||
class Post extends \Spawnia\Sailor\ObjectLike | ||
{ | ||
/** | ||
* @param \Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node\Node\User|\Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node\Node\Task|\Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node\Node\Post|null $node | ||
*/ | ||
public static function make($node = 'Special default value that allows Sailor to differentiate between explicitly passing null and not passing a value at all.'): self | ||
{ | ||
$instance = new self; | ||
|
||
$instance->__typename = 'Node'; | ||
if ($node !== self::UNDEFINED) { | ||
$instance->node = $node; | ||
} | ||
|
||
return $instance; | ||
} | ||
|
||
protected function converters(): array | ||
{ | ||
static $converters; | ||
|
||
return $converters ??= [ | ||
'__typename' => new \Spawnia\Sailor\Convert\NonNullConverter(new \Spawnia\Sailor\Convert\StringConverter), | ||
'node' => new \Spawnia\Sailor\Convert\NullConverter(new \Spawnia\Sailor\Convert\PolymorphicConverter([ | ||
'User' => '\\Spawnia\\Sailor\\Polymorphic\\Operations\\NodeWithFragments\\Node\\Node\\Node\\User', | ||
'Task' => '\\Spawnia\\Sailor\\Polymorphic\\Operations\\NodeWithFragments\\Node\\Node\\Node\\Task', | ||
'Post' => '\\Spawnia\\Sailor\\Polymorphic\\Operations\\NodeWithFragments\\Node\\Node\\Node\\Post', | ||
])), | ||
]; | ||
} | ||
|
||
public static function endpoint(): string | ||
{ | ||
return 'polymorphic'; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
examples/polymorphic/expected/Operations/NodeWithFragments/Node/Node/Task.php
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,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node; | ||
|
||
/** | ||
* @property string $__typename | ||
* @property \Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node\Node\User|\Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node\Node\Task|\Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node\Node\Post|null $node | ||
*/ | ||
class Task extends \Spawnia\Sailor\ObjectLike | ||
{ | ||
/** | ||
* @param \Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node\Node\User|\Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node\Node\Task|\Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node\Node\Post|null $node | ||
*/ | ||
public static function make($node = 'Special default value that allows Sailor to differentiate between explicitly passing null and not passing a value at all.'): self | ||
{ | ||
$instance = new self; | ||
|
||
$instance->__typename = 'Node'; | ||
if ($node !== self::UNDEFINED) { | ||
$instance->node = $node; | ||
} | ||
|
||
return $instance; | ||
} | ||
|
||
protected function converters(): array | ||
{ | ||
static $converters; | ||
|
||
return $converters ??= [ | ||
'__typename' => new \Spawnia\Sailor\Convert\NonNullConverter(new \Spawnia\Sailor\Convert\StringConverter), | ||
'node' => new \Spawnia\Sailor\Convert\NullConverter(new \Spawnia\Sailor\Convert\PolymorphicConverter([ | ||
'User' => '\\Spawnia\\Sailor\\Polymorphic\\Operations\\NodeWithFragments\\Node\\Node\\Node\\User', | ||
'Task' => '\\Spawnia\\Sailor\\Polymorphic\\Operations\\NodeWithFragments\\Node\\Node\\Node\\Task', | ||
'Post' => '\\Spawnia\\Sailor\\Polymorphic\\Operations\\NodeWithFragments\\Node\\Node\\Node\\Post', | ||
])), | ||
]; | ||
} | ||
|
||
public static function endpoint(): string | ||
{ | ||
return 'polymorphic'; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
examples/polymorphic/expected/Operations/NodeWithFragments/Node/Node/User.php
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,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node; | ||
|
||
/** | ||
* @property string $__typename | ||
* @property \Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node\Node\User|\Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node\Node\Task|\Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node\Node\Post|null $node | ||
*/ | ||
class User extends \Spawnia\Sailor\ObjectLike | ||
{ | ||
/** | ||
* @param \Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node\Node\User|\Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node\Node\Task|\Spawnia\Sailor\Polymorphic\Operations\NodeWithFragments\Node\Node\Node\Post|null $node | ||
*/ | ||
public static function make($node = 'Special default value that allows Sailor to differentiate between explicitly passing null and not passing a value at all.'): self | ||
{ | ||
$instance = new self; | ||
|
||
$instance->__typename = 'Node'; | ||
if ($node !== self::UNDEFINED) { | ||
$instance->node = $node; | ||
} | ||
|
||
return $instance; | ||
} | ||
|
||
protected function converters(): array | ||
{ | ||
static $converters; | ||
|
||
return $converters ??= [ | ||
'__typename' => new \Spawnia\Sailor\Convert\NonNullConverter(new \Spawnia\Sailor\Convert\StringConverter), | ||
'node' => new \Spawnia\Sailor\Convert\NullConverter(new \Spawnia\Sailor\Convert\PolymorphicConverter([ | ||
'User' => '\\Spawnia\\Sailor\\Polymorphic\\Operations\\NodeWithFragments\\Node\\Node\\Node\\User', | ||
'Task' => '\\Spawnia\\Sailor\\Polymorphic\\Operations\\NodeWithFragments\\Node\\Node\\Node\\Task', | ||
'Post' => '\\Spawnia\\Sailor\\Polymorphic\\Operations\\NodeWithFragments\\Node\\Node\\Node\\Post', | ||
])), | ||
]; | ||
} | ||
|
||
public static function endpoint(): string | ||
{ | ||
return 'polymorphic'; | ||
} | ||
} |
Oops, something went wrong.