| 1 | <?php |
||
| 9 | * http://opensource.org/licenses/MIT |
||
| 10 | */ |
||
| 11 | |||
| 12 | declare(strict_types=1); |
||
| 13 | |||
| 14 | namespace Youshido\Tests\Issues\Issue90; |
||
| 15 | |||
| 16 | use Youshido\GraphQL\Config\Schema\SchemaConfig; |
||
| 17 | use Youshido\GraphQL\Schema\AbstractSchema; |
||
| 18 | use Youshido\GraphQL\Type\Object\ObjectType; |
||
| 19 | use Youshido\GraphQL\Type\Scalar\DateTimeType; |
||
| 20 | |||
| 21 | class Issue90Schema extends AbstractSchema |
||
| 22 | { |
||
| 23 | public function build(SchemaConfig $config): void |
||
| 24 | { |
||
| 25 | $config->setQuery( |
||
| 26 | new ObjectType([ |
||
| 27 | 'name' => 'QueryType', |
||
| 28 | 'fields' => [ |
||
| 29 | 'echo' => [ |
||
| 30 | 'type' => new DateTimeType('Y-m-d H:ia'), |
||
| 31 | 'args' => [ |
||
| 32 | 'date' => new DateTimeType('Y-m-d H:ia'), |
||
| 33 | ], |
||
| 34 | 'resolve' => static function ($value, $args, $info) { |
||
| 35 | if (isset($args['date'])) { |
||
| 36 | return $args['date']; |
||
| 37 | } |
||
| 38 | }, |
||
| 39 | ], |
||
| 40 | ], |
||
| 41 | ]) |
||
| 42 | ); |
||
| 43 | |||
| 44 | $config->setMutation( |
||
| 45 | new ObjectType([ |
||
| 46 | 'name' => 'MutationType', |
||
| 47 | 'fields' => [ |
||
| 48 | 'echo' => [ |
||
| 49 | 'type' => new DateTimeType('Y-m-d H:ia'), |
||
| 50 | 'args' => [ |
||
| 51 | 'date' => new DateTimeType('Y-m-d H:ia'), |
||
| 52 | ], |
||
| 53 | 'resolve' => static function ($value, $args, $info) { |
||
| 54 | if (isset($args['date'])) { |
||
| 55 | return $args['date']; |
||
| 56 | } |
||
| 57 | }, |
||
| 58 | ], |
||
| 59 | ], |
||
| 60 | ]) |
||
| 64 |