@@ -37,7 +37,7 @@ |
||
37 | 37 | return false; |
38 | 38 | } |
39 | 39 | |
40 | - $requiredFields = array_filter($this->getConfig()->getFields(), function (Field $field) { |
|
40 | + $requiredFields = array_filter($this->getConfig()->getFields(), function(Field $field) { |
|
41 | 41 | return $field->getConfig()->isRequired(); |
42 | 42 | }); |
43 | 43 |
@@ -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(); |
12 | 12 | $processor->setSchema(new Schema([ |
@@ -24,4 +24,4 @@ discard block |
||
24 | 24 | ])); |
25 | 25 | |
26 | 26 | $res = $processor->processRequest('{ currentTime }')->getResponseData(); |
27 | -echo json_encode($res) . "\n\n"; |
|
27 | +echo json_encode($res)."\n\n"; |
@@ -12,16 +12,16 @@ |
||
12 | 12 | use Youshido\GraphQL\Type\ListType\ListType; |
13 | 13 | use Youshido\GraphQL\Type\Object\ObjectType; |
14 | 14 | |
15 | -require_once __DIR__ . '/../../vendor/autoload.php'; |
|
16 | -require_once __DIR__ . '/Schema/DataProvider.php'; |
|
17 | -require_once __DIR__ . '/Schema/PostType.php'; |
|
18 | -require_once __DIR__ . '/Schema/PostStatus.php'; |
|
19 | -require_once __DIR__ . '/Schema/ContentBlockInterface.php'; |
|
20 | -require_once __DIR__ . '/Schema/LikePost.php'; |
|
21 | -require_once __DIR__ . '/Schema/BannerType.php'; |
|
22 | -require_once __DIR__ . '/Schema/ContentBlockUnion.php'; |
|
23 | -require_once __DIR__ . '/Schema/PostInputType.php'; |
|
24 | -require_once __DIR__ . '/Schema/BlogSchema.php'; |
|
15 | +require_once __DIR__.'/../../vendor/autoload.php'; |
|
16 | +require_once __DIR__.'/Schema/DataProvider.php'; |
|
17 | +require_once __DIR__.'/Schema/PostType.php'; |
|
18 | +require_once __DIR__.'/Schema/PostStatus.php'; |
|
19 | +require_once __DIR__.'/Schema/ContentBlockInterface.php'; |
|
20 | +require_once __DIR__.'/Schema/LikePost.php'; |
|
21 | +require_once __DIR__.'/Schema/BannerType.php'; |
|
22 | +require_once __DIR__.'/Schema/ContentBlockUnion.php'; |
|
23 | +require_once __DIR__.'/Schema/PostInputType.php'; |
|
24 | +require_once __DIR__.'/Schema/BlogSchema.php'; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | $rootQueryType = new ObjectType([ |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | use Youshido\GraphQL\Processor; |
7 | 7 | use Youshido\GraphQL\Schema; |
8 | 8 | |
9 | -require_once __DIR__ . '/schema-bootstrap.php'; |
|
9 | +require_once __DIR__.'/schema-bootstrap.php'; |
|
10 | 10 | /** @var Schema $schema */ |
11 | 11 | $schema = new BlogSchema(); |
12 | 12 | |
@@ -20,4 +20,4 @@ discard block |
||
20 | 20 | $payload = '{ pageContentInterface { title} }'; |
21 | 21 | $response = $processor->processRequest($payload, [])->getResponseData(); |
22 | 22 | |
23 | -echo json_encode($response) . "\n\n"; |
|
23 | +echo json_encode($response)."\n\n"; |
@@ -11,7 +11,7 @@ |
||
11 | 11 | use Youshido\GraphQL\Processor; |
12 | 12 | use Youshido\GraphQL\Schema; |
13 | 13 | |
14 | -require_once __DIR__ . '/schema-bootstrap.php'; |
|
14 | +require_once __DIR__.'/schema-bootstrap.php'; |
|
15 | 15 | /** @var Schema $schema */ |
16 | 16 | $schema = new BlogSchema(); |
17 | 17 |
@@ -18,19 +18,19 @@ |
||
18 | 18 | 'latestPost' => new PostType(), |
19 | 19 | 'randomBanner' => [ |
20 | 20 | 'type' => new BannerType(), |
21 | - 'resolve' => function () { |
|
21 | + 'resolve' => function() { |
|
22 | 22 | return DataProvider::getBanner(rand(1, 10)); |
23 | 23 | } |
24 | 24 | ], |
25 | 25 | 'pageContentUnion' => [ |
26 | 26 | 'type' => new ListType(new ContentBlockUnion()), |
27 | - 'resolve' => function () { |
|
27 | + 'resolve' => function() { |
|
28 | 28 | return [DataProvider::getPost(1), DataProvider::getBanner(1)]; |
29 | 29 | } |
30 | 30 | ], |
31 | 31 | 'pageContentInterface' => [ |
32 | 32 | 'type' => new ListType(new ContentBlockInterface()), |
33 | - 'resolve' => function () { |
|
33 | + 'resolve' => function() { |
|
34 | 34 | return [DataProvider::getPost(2), DataProvider::getBanner(3)]; |
35 | 35 | } |
36 | 36 | ] |
@@ -25,8 +25,8 @@ |
||
25 | 25 | 'args' => [ |
26 | 26 | 'truncated' => new BooleanType() |
27 | 27 | ], |
28 | - 'resolve' => function ($value, $args) { |
|
29 | - return (!empty($args['truncated'])) ? explode(' ', $value)[0] . '...' : $value; |
|
28 | + 'resolve' => function($value, $args) { |
|
29 | + return (!empty($args['truncated'])) ? explode(' ', $value)[0].'...' : $value; |
|
30 | 30 | } |
31 | 31 | ]) |
32 | 32 | ->addField('title', new NonNullType(new StringType())) |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | public static function getPost($id) |
11 | 11 | { |
12 | 12 | return [ |
13 | - "id" => "post-" . $id, |
|
14 | - "title" => "Post " . $id . " title", |
|
13 | + "id" => "post-".$id, |
|
14 | + "title" => "Post ".$id." title", |
|
15 | 15 | "summary" => "This new GraphQL library for PHP works really well", |
16 | 16 | "status" => 1, |
17 | 17 | "likeCount" => 2 |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | public static function getBanner($id) |
22 | 22 | { |
23 | 23 | return [ |
24 | - 'id' => "banner-" . $id, |
|
25 | - 'title' => "Banner " . $id, |
|
26 | - 'imageLink' => "banner" . $id . ".jpg" |
|
24 | + 'id' => "banner-".$id, |
|
25 | + 'title' => "Banner ".$id, |
|
26 | + 'imageLink' => "banner".$id.".jpg" |
|
27 | 27 | ]; |
28 | 28 | } |
29 | 29 | } |
@@ -17,16 +17,16 @@ discard block |
||
17 | 17 | 'fields' => [ |
18 | 18 | // here you have a complex field with a lot of options |
19 | 19 | 'title' => [ |
20 | - 'type' => new StringType(), // string type |
|
21 | - 'description' => 'This field contains a post title', // description |
|
22 | - 'isDeprecated' => true, // marked as deprecated |
|
23 | - 'deprecationReason' => 'field title is now deprecated', // explain the reason |
|
20 | + 'type' => new StringType(), // string type |
|
21 | + 'description' => 'This field contains a post title', // description |
|
22 | + 'isDeprecated' => true, // marked as deprecated |
|
23 | + 'deprecationReason' => 'field title is now deprecated', // explain the reason |
|
24 | 24 | 'args' => [ |
25 | 25 | 'truncated' => new BooleanType() // add an optional argument |
26 | 26 | ], |
27 | - 'resolve' => function ($value, $args) { |
|
27 | + 'resolve' => function($value, $args) { |
|
28 | 28 | // used argument to modify a field value |
29 | - return (!empty($args['truncated'])) ? explode(' ', $value)[0] . '...' : $value; |
|
29 | + return (!empty($args['truncated'])) ? explode(' ', $value)[0].'...' : $value; |
|
30 | 30 | } |
31 | 31 | ], |
32 | 32 | // if field just has a type, you can use a short declaration syntax like this |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | 'id' => new IntType() |
39 | 39 | ], |
40 | 40 | // resolve function for the query |
41 | - 'resolve' => function ($value, $args, $type) { |
|
41 | + 'resolve' => function($value, $args, $type) { |
|
42 | 42 | return [ |
43 | 43 | 'title' => 'Title for the latest Post', |
44 | 44 | 'summary' => 'Post summary', |