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.
Do not assume scalar values are
string
, use mixed
- Loading branch information
Showing
11 changed files
with
210 additions
and
19 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
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
48 changes: 48 additions & 0 deletions
48
examples/custom-types/expected/Operations/MyDefaultDateQuery.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,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Spawnia\Sailor\CustomTypes\Operations; | ||
|
||
/** | ||
* @extends \Spawnia\Sailor\Operation<\Spawnia\Sailor\CustomTypes\Operations\MyDefaultDateQuery\MyDefaultDateQueryResult> | ||
*/ | ||
class MyDefaultDateQuery extends \Spawnia\Sailor\Operation | ||
{ | ||
/** | ||
* @param mixed $value | ||
*/ | ||
public static function execute($value): MyDefaultDateQuery\MyDefaultDateQueryResult | ||
{ | ||
return self::executeOperation( | ||
$value, | ||
); | ||
} | ||
|
||
protected static function converters(): array | ||
{ | ||
static $converters; | ||
|
||
return $converters ??= [ | ||
['value', new \Spawnia\Sailor\Convert\NonNullConverter(new \Spawnia\Sailor\Convert\ScalarConverter)], | ||
]; | ||
} | ||
|
||
public static function document(): string | ||
{ | ||
return /* @lang GraphQL */ 'query MyDefaultDateQuery($value: DefaultDate!) { | ||
__typename | ||
withDefaultDate(value: $value) | ||
}'; | ||
} | ||
|
||
public static function endpoint(): string | ||
{ | ||
return 'custom-types'; | ||
} | ||
|
||
public static function config(): string | ||
{ | ||
return \Safe\realpath(__DIR__ . '/../../sailor.php'); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
examples/custom-types/expected/Operations/MyDefaultDateQuery/MyDefaultDateQuery.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,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Spawnia\Sailor\CustomTypes\Operations\MyDefaultDateQuery; | ||
|
||
/** | ||
* @property mixed $withDefaultDate | ||
* @property string $__typename | ||
*/ | ||
class MyDefaultDateQuery extends \Spawnia\Sailor\ObjectLike | ||
{ | ||
/** | ||
* @param mixed $withDefaultDate | ||
*/ | ||
public static function make($withDefaultDate): self | ||
{ | ||
$instance = new self; | ||
|
||
if ($withDefaultDate !== self::UNDEFINED) { | ||
$instance->withDefaultDate = $withDefaultDate; | ||
} | ||
$instance->__typename = 'Query'; | ||
|
||
return $instance; | ||
} | ||
|
||
protected function converters(): array | ||
{ | ||
static $converters; | ||
|
||
return $converters ??= [ | ||
'withDefaultDate' => new \Spawnia\Sailor\Convert\NonNullConverter(new \Spawnia\Sailor\Convert\ScalarConverter), | ||
'__typename' => new \Spawnia\Sailor\Convert\NonNullConverter(new \Spawnia\Sailor\Convert\StringConverter), | ||
]; | ||
} | ||
|
||
public static function endpoint(): string | ||
{ | ||
return 'custom-types'; | ||
} | ||
|
||
public static function config(): string | ||
{ | ||
return \Safe\realpath(__DIR__ . '/../../../sailor.php'); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...custom-types/expected/Operations/MyDefaultDateQuery/MyDefaultDateQueryErrorFreeResult.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,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Spawnia\Sailor\CustomTypes\Operations\MyDefaultDateQuery; | ||
|
||
class MyDefaultDateQueryErrorFreeResult extends \Spawnia\Sailor\ErrorFreeResult | ||
{ | ||
public MyDefaultDateQuery $data; | ||
|
||
public static function endpoint(): string | ||
{ | ||
return 'custom-types'; | ||
} | ||
|
||
public static function config(): string | ||
{ | ||
return \Safe\realpath(__DIR__ . '/../../../sailor.php'); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
examples/custom-types/expected/Operations/MyDefaultDateQuery/MyDefaultDateQueryResult.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,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Spawnia\Sailor\CustomTypes\Operations\MyDefaultDateQuery; | ||
|
||
class MyDefaultDateQueryResult extends \Spawnia\Sailor\Result | ||
{ | ||
public ?MyDefaultDateQuery $data = null; | ||
|
||
protected function setData(\stdClass $data): void | ||
{ | ||
$this->data = MyDefaultDateQuery::fromStdClass($data); | ||
} | ||
|
||
/** | ||
* Useful for instantiation of successful mocked results. | ||
* | ||
* @return static | ||
*/ | ||
public static function fromData(MyDefaultDateQuery $data): self | ||
{ | ||
$instance = new static; | ||
$instance->data = $data; | ||
|
||
return $instance; | ||
} | ||
|
||
public function errorFree(): MyDefaultDateQueryErrorFreeResult | ||
{ | ||
return MyDefaultDateQueryErrorFreeResult::fromResult($this); | ||
} | ||
|
||
public static function endpoint(): string | ||
{ | ||
return 'custom-types'; | ||
} | ||
|
||
public static function config(): string | ||
{ | ||
return \Safe\realpath(__DIR__ . '/../../../sailor.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
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,3 @@ | ||
query MyDefaultDateQuery($value: DefaultDate!) { | ||
withDefaultDate(value: $value) | ||
} |
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
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