@@ -24,7 +24,7 @@ |
||
| 24 | 24 | if (!is_array($types)) { |
| 25 | 25 | throw new \Exception('addTypes accept only array of types'); |
| 26 | 26 | } |
| 27 | - foreach($types as $type) { |
|
| 27 | + foreach ($types as $type) { |
|
| 28 | 28 | $this->addType($type); |
| 29 | 29 | } |
| 30 | 30 | return $this; |
@@ -42,7 +42,9 @@ discard block |
||
| 42 | 42 | public function addType(TypeInterface $type) |
| 43 | 43 | { |
| 44 | 44 | $typeName = $this->getTypeName($type); |
| 45 | - if ($this->isTypeNameRegistered($typeName)) return $this; |
|
| 45 | + if ($this->isTypeNameRegistered($typeName)) { |
|
| 46 | + return $this; |
|
| 47 | + } |
|
| 46 | 48 | |
| 47 | 49 | $this->typesList[$typeName] = $type; |
| 48 | 50 | return $this; |
@@ -54,7 +56,9 @@ discard block |
||
| 54 | 56 | } |
| 55 | 57 | |
| 56 | 58 | private function getTypeName($type) { |
| 57 | - if (is_string($type)) return $type; |
|
| 59 | + if (is_string($type)) { |
|
| 60 | + return $type; |
|
| 61 | + } |
|
| 58 | 62 | if (is_object($type) && $type instanceof AbstractType) { |
| 59 | 63 | return $type->getName(); |
| 60 | 64 | } |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require_once __DIR__ . '/../../../../../vendor/autoload.php'; |
|
| 4 | -require_once __DIR__ . '/Schema/FactionType.php'; |
|
| 5 | -require_once __DIR__ . '/Schema/ShipType.php'; |
|
| 6 | -require_once __DIR__ . '/Schema/TestDataProvider.php'; |
|
| 7 | -require_once __DIR__ . '/Schema/StarWarsRelaySchema.php'; |
|
| 3 | +require_once __DIR__.'/../../../../../vendor/autoload.php'; |
|
| 4 | +require_once __DIR__.'/Schema/FactionType.php'; |
|
| 5 | +require_once __DIR__.'/Schema/ShipType.php'; |
|
| 6 | +require_once __DIR__.'/Schema/TestDataProvider.php'; |
|
| 7 | +require_once __DIR__.'/Schema/StarWarsRelaySchema.php'; |
|
@@ -2,13 +2,13 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace BlogTest; |
| 4 | 4 | |
| 5 | -require_once __DIR__ . '/../../../../../vendor/autoload.php'; |
|
| 6 | -require_once __DIR__ . '/Schema/DataProvider.php'; |
|
| 7 | -require_once __DIR__ . '/Schema/PostType.php'; |
|
| 8 | -require_once __DIR__ . '/Schema/PostStatus.php'; |
|
| 9 | -require_once __DIR__ . '/Schema/ContentBlockInterface.php'; |
|
| 10 | -require_once __DIR__ . '/Schema/LikePostField.php'; |
|
| 11 | -require_once __DIR__ . '/Schema/BannerType.php'; |
|
| 12 | -require_once __DIR__ . '/Schema/ContentBlockUnion.php'; |
|
| 13 | -require_once __DIR__ . '/Schema/PostInputType.php'; |
|
| 14 | -require_once __DIR__ . '/Schema/BlogSchema.php'; |
|
| 5 | +require_once __DIR__.'/../../../../../vendor/autoload.php'; |
|
| 6 | +require_once __DIR__.'/Schema/DataProvider.php'; |
|
| 7 | +require_once __DIR__.'/Schema/PostType.php'; |
|
| 8 | +require_once __DIR__.'/Schema/PostStatus.php'; |
|
| 9 | +require_once __DIR__.'/Schema/ContentBlockInterface.php'; |
|
| 10 | +require_once __DIR__.'/Schema/LikePostField.php'; |
|
| 11 | +require_once __DIR__.'/Schema/BannerType.php'; |
|
| 12 | +require_once __DIR__.'/Schema/ContentBlockUnion.php'; |
|
| 13 | +require_once __DIR__.'/Schema/PostInputType.php'; |
|
| 14 | +require_once __DIR__.'/Schema/BlogSchema.php'; |
|
@@ -7,8 +7,8 @@ discard block |
||
| 7 | 7 | use Youshido\GraphQL\Type\Object\ObjectType; |
| 8 | 8 | |
| 9 | 9 | |
| 10 | -require_once __DIR__ . '/../../../../../vendor/autoload.php'; |
|
| 11 | -require_once __DIR__ . '/inline-schema.php'; |
|
| 10 | +require_once __DIR__.'/../../../../../vendor/autoload.php'; |
|
| 11 | +require_once __DIR__.'/inline-schema.php'; |
|
| 12 | 12 | /** @var ObjectType $rootQueryType */ |
| 13 | 13 | |
| 14 | 14 | $processor = new Processor(new Schema([ |
@@ -17,4 +17,4 @@ discard block |
||
| 17 | 17 | $payload = '{ latestPost { title(truncated: true), summary } }'; |
| 18 | 18 | |
| 19 | 19 | $processor->processPayload($payload); |
| 20 | -echo json_encode($processor->getResponseData()) . "\n"; |
|
| 20 | +echo json_encode($processor->getResponseData())."\n"; |
|
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | use Youshido\GraphQL\Type\Object\ObjectType; |
| 7 | 7 | use Youshido\GraphQL\Type\Scalar\StringType; |
| 8 | 8 | |
| 9 | -require_once __DIR__ . '/../../../../../vendor/autoload.php'; |
|
| 9 | +require_once __DIR__.'/../../../../../vendor/autoload.php'; |
|
| 10 | 10 | |
| 11 | 11 | $processor = new Processor(new Schema([ |
| 12 | 12 | 'query' => new ObjectType([ |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | 'fields' => [ |
| 15 | 15 | 'currentTime' => [ |
| 16 | 16 | 'type' => new StringType(), |
| 17 | - 'resolve' => function () { |
|
| 17 | + 'resolve' => function() { |
|
| 18 | 18 | return date('Y-m-d H:ia'); |
| 19 | 19 | } |
| 20 | 20 | ] |
@@ -23,4 +23,4 @@ discard block |
||
| 23 | 23 | ])); |
| 24 | 24 | |
| 25 | 25 | $processor->processPayload('{ currentTime }'); |
| 26 | -echo json_encode($processor->getResponseData()) . "\n"; |
|
| 26 | +echo json_encode($processor->getResponseData())."\n"; |
|
@@ -23,6 +23,9 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | private $typesList; |
| 25 | 25 | |
| 26 | + /** |
|
| 27 | + * @param \Youshido\GraphQL\Schema\AbstractSchema $contextObject |
|
| 28 | + */ |
|
| 26 | 29 | public function __construct(array $configData, $contextObject = null, $finalClass = false) |
| 27 | 30 | { |
| 28 | 31 | $this->typesList = new SchemaTypesList(); |
@@ -58,7 +61,7 @@ discard block |
||
| 58 | 61 | } |
| 59 | 62 | |
| 60 | 63 | /** |
| 61 | - * @param $query AbstractObjectType |
|
| 64 | + * @param \Youshido\Tests\StarWars\Schema\StarWarsQueryType $query AbstractObjectType |
|
| 62 | 65 | * |
| 63 | 66 | * @return SchemaConfig |
| 64 | 67 | */ |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | 'fields' => [ |
| 30 | 30 | 'currentTime' => [ |
| 31 | 31 | 'type' => new StringType(), |
| 32 | - 'resolve' => function ($value, $args, $type) { |
|
| 32 | + 'resolve' => function($value, $args, $type) { |
|
| 33 | 33 | return 'May 5, 9:00am'; |
| 34 | 34 | }, |
| 35 | 35 | 'args' => [ |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | $this->assertEquals(1, count($schema->getMutationType()->getFields())); |
| 60 | 60 | |
| 61 | - $schema->addMutationField('changeUser', ['type' => new TestObjectType(), 'resolve' => function () { }]); |
|
| 61 | + $schema->addMutationField('changeUser', ['type' => new TestObjectType(), 'resolve' => function() { }]); |
|
| 62 | 62 | $this->assertEquals(2, count($schema->getMutationType()->getFields())); |
| 63 | 63 | |
| 64 | 64 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | 'fields' => [ |
| 90 | 90 | 'name' => new StringType(), |
| 91 | 91 | ], |
| 92 | - 'resolveType' => function () use ($authorType) { |
|
| 92 | + 'resolveType' => function() use ($authorType) { |
|
| 93 | 93 | return $authorType; |
| 94 | 94 | } |
| 95 | 95 | ]); |
@@ -102,13 +102,13 @@ discard block |
||
| 102 | 102 | 'interfaces' => [$userInterface] |
| 103 | 103 | ]); |
| 104 | 104 | |
| 105 | - $schema = new Schema([ |
|
| 105 | + $schema = new Schema([ |
|
| 106 | 106 | 'query' => new ObjectType([ |
| 107 | 107 | 'name' => 'QueryType', |
| 108 | 108 | 'fields' => [ |
| 109 | 109 | 'user' => [ |
| 110 | 110 | 'type' => $userInterface, |
| 111 | - 'resolve' => function () { |
|
| 111 | + 'resolve' => function() { |
|
| 112 | 112 | return [ |
| 113 | 113 | 'name' => 'Alex' |
| 114 | 114 | ]; |