@@ -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 | } |
@@ -42,8 +42,8 @@ |
||
| 42 | 42 | public function getDescription() |
| 43 | 43 | { |
| 44 | 44 | return 'The `String` scalar type represents textual data, represented as UTF-8 ' . |
| 45 | - 'character sequences. The String type is most often used by GraphQL to ' . |
|
| 46 | - 'represent free-form human-readable text.'; |
|
| 45 | + 'character sequences. The String type is most often used by GraphQL to ' . |
|
| 46 | + 'represent free-form human-readable text.'; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * http://opensource.org/licenses/MIT |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -declare(strict_types=1); |
|
| 12 | +declare(strict_types = 1); |
|
| 13 | 13 | /* |
| 14 | 14 | * This file is a part of graphql-youshido project. |
| 15 | 15 | * |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | return ''; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - return (string) $value; |
|
| 47 | + return (string)$value; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | public function isValidValue($value) |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | public function getDescription() |
| 56 | 56 | { |
| 57 | - return 'The `String` scalar type represents textual data, represented as UTF-8 ' . |
|
| 58 | - 'character sequences. The String type is most often used by GraphQL to ' . |
|
| 57 | + return 'The `String` scalar type represents textual data, represented as UTF-8 '. |
|
| 58 | + 'character sequences. The String type is most often used by GraphQL to '. |
|
| 59 | 59 | 'represent free-form human-readable text.'; |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -29,8 +29,8 @@ |
||
| 29 | 29 | public function getDescription() |
| 30 | 30 | { |
| 31 | 31 | return 'The `Float` scalar type represents signed double-precision fractional ' . |
| 32 | - 'values as specified by ' . |
|
| 33 | - '[IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point).'; |
|
| 32 | + 'values as specified by ' . |
|
| 33 | + '[IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point).'; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * http://opensource.org/licenses/MIT |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -declare(strict_types=1); |
|
| 12 | +declare(strict_types = 1); |
|
| 13 | 13 | /* |
| 14 | 14 | * This file is a part of graphql-youshido project. |
| 15 | 15 | * |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | return; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - return (float) $value; |
|
| 35 | + return (float)$value; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | public function isValidValue($value) |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | public function getDescription() |
| 44 | 44 | { |
| 45 | - return 'The `Float` scalar type represents signed double-precision fractional ' . |
|
| 46 | - 'values as specified by ' . |
|
| 45 | + return 'The `Float` scalar type represents signed double-precision fractional '. |
|
| 46 | + 'values as specified by '. |
|
| 47 | 47 | '[IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point).'; |
| 48 | 48 | } |
| 49 | 49 | } |
@@ -40,9 +40,9 @@ |
||
| 40 | 40 | public function getDescription() |
| 41 | 41 | { |
| 42 | 42 | return 'The `Int` scalar type represents non-fractional signed whole numeric ' . |
| 43 | - 'values. Int can represent values between -(2^53 - 1) and 2^53 - 1 since ' . |
|
| 44 | - 'represented in JSON as double-precision floating point numbers specified' . |
|
| 45 | - 'by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point).'; |
|
| 43 | + 'values. Int can represent values between -(2^53 - 1) and 2^53 - 1 since ' . |
|
| 44 | + 'represented in JSON as double-precision floating point numbers specified' . |
|
| 45 | + 'by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point).'; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * http://opensource.org/licenses/MIT |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -declare(strict_types=1); |
|
| 12 | +declare(strict_types = 1); |
|
| 13 | 13 | /* |
| 14 | 14 | * This file is a part of graphql-youshido project. |
| 15 | 15 | * |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | if (\is_int($value)) { |
| 36 | 36 | return $value; |
| 37 | 37 | } |
| 38 | - $value = (int) $value; |
|
| 38 | + $value = (int)$value; |
|
| 39 | 39 | |
| 40 | 40 | return 0 !== $value ? $value : null; |
| 41 | 41 | } |
@@ -47,9 +47,9 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | public function getDescription() |
| 49 | 49 | { |
| 50 | - return 'The `Int` scalar type represents non-fractional signed whole numeric ' . |
|
| 51 | - 'values. Int can represent values between -(2^53 - 1) and 2^53 - 1 since ' . |
|
| 52 | - 'represented in JSON as double-precision floating point numbers specified' . |
|
| 50 | + return 'The `Int` scalar type represents non-fractional signed whole numeric '. |
|
| 51 | + 'values. Int can represent values between -(2^53 - 1) and 2^53 - 1 since '. |
|
| 52 | + 'represented in JSON as double-precision floating point numbers specified'. |
|
| 53 | 53 | 'by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point).'; |
| 54 | 54 | } |
| 55 | 55 | } |
@@ -30,9 +30,9 @@ |
||
| 30 | 30 | public function getDescription() |
| 31 | 31 | { |
| 32 | 32 | return 'The `ID` scalar type represents a unique identifier, often used to ' . |
| 33 | - 'refetch an object or as key for a cache. The ID type appears in a JSON ' . |
|
| 34 | - 'response as a String; however, it is not intended to be human-readable. ' . |
|
| 35 | - 'When expected as an input type, any string (such as `"4"`) or integer ' . |
|
| 36 | - '(such as `4`) input value will be accepted as an ID.'; |
|
| 33 | + 'refetch an object or as key for a cache. The ID type appears in a JSON ' . |
|
| 34 | + 'response as a String; however, it is not intended to be human-readable. ' . |
|
| 35 | + 'When expected as an input type, any string (such as `"4"`) or integer ' . |
|
| 36 | + '(such as `4`) input value will be accepted as an ID.'; |
|
| 37 | 37 | } |
| 38 | 38 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * http://opensource.org/licenses/MIT |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -declare(strict_types=1); |
|
| 12 | +declare(strict_types = 1); |
|
| 13 | 13 | /* |
| 14 | 14 | * This file is a part of GraphQL project. |
| 15 | 15 | * |
@@ -32,15 +32,15 @@ discard block |
||
| 32 | 32 | return; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - return (string) $value; |
|
| 35 | + return (string)$value; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | public function getDescription() |
| 39 | 39 | { |
| 40 | - return 'The `ID` scalar type represents a unique identifier, often used to ' . |
|
| 41 | - 'refetch an object or as key for a cache. The ID type appears in a JSON ' . |
|
| 42 | - 'response as a String; however, it is not intended to be human-readable. ' . |
|
| 43 | - 'When expected as an input type, any string (such as `"4"`) or integer ' . |
|
| 40 | + return 'The `ID` scalar type represents a unique identifier, often used to '. |
|
| 41 | + 'refetch an object or as key for a cache. The ID type appears in a JSON '. |
|
| 42 | + 'response as a String; however, it is not intended to be human-readable. '. |
|
| 43 | + 'When expected as an input type, any string (such as `"4"`) or integer '. |
|
| 44 | 44 | '(such as `4`) input value will be accepted as an ID.'; |
| 45 | 45 | } |
| 46 | 46 | } |
@@ -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 |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | 'id' => new IntType() |
| 40 | 40 | ], |
| 41 | 41 | // resolve function for the query |
| 42 | - 'resolve' => function () { |
|
| 42 | + 'resolve' => function() { |
|
| 43 | 43 | return [ |
| 44 | 44 | 'title' => 'Title for the latest Post', |
| 45 | 45 | 'summary' => 'Post summary', |
@@ -18,25 +18,25 @@ discard block |
||
| 18 | 18 | $config->getQuery()->addFields([ |
| 19 | 19 | 'latestPost' => [ |
| 20 | 20 | 'type' => new PostType(), |
| 21 | - 'resolve' => function ($value, array $args, ResolveInfo $info) { |
|
| 21 | + 'resolve' => function($value, array $args, ResolveInfo $info) { |
|
| 22 | 22 | return $info->getReturnType()->getOne(empty($args['id']) ? 1 : $args['id']); |
| 23 | 23 | } |
| 24 | 24 | ], |
| 25 | 25 | 'randomBanner' => [ |
| 26 | 26 | 'type' => new BannerType(), |
| 27 | - 'resolve' => function () { |
|
| 27 | + 'resolve' => function() { |
|
| 28 | 28 | return DataProvider::getBanner(rand(1, 10)); |
| 29 | 29 | } |
| 30 | 30 | ], |
| 31 | 31 | 'pageContentUnion' => [ |
| 32 | 32 | 'type' => new ListType(new ContentBlockUnion()), |
| 33 | - 'resolve' => function () { |
|
| 33 | + 'resolve' => function() { |
|
| 34 | 34 | return [DataProvider::getPost(1), DataProvider::getBanner(1)]; |
| 35 | 35 | } |
| 36 | 36 | ], |
| 37 | 37 | 'pageContentInterface' => [ |
| 38 | 38 | 'type' => new ListType(new ContentBlockInterface()), |
| 39 | - 'resolve' => function () { |
|
| 39 | + 'resolve' => function() { |
|
| 40 | 40 | return [DataProvider::getPost(2), DataProvider::getBanner(3)]; |
| 41 | 41 | } |
| 42 | 42 | ] |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | 'post' => new PostInputType(), |
| 50 | 50 | 'author' => new StringType() |
| 51 | 51 | ], |
| 52 | - 'resolve' => function ($value, array $args, ResolveInfo $info) { |
|
| 52 | + 'resolve' => function($value, array $args, ResolveInfo $info) { |
|
| 53 | 53 | // code for creating a new post goes here |
| 54 | 54 | // we simple use our DataProvider for now |
| 55 | 55 | $post = DataProvider::getPost(10); |
@@ -40,8 +40,8 @@ |
||
| 40 | 40 | 'type' => Connection::connectionDefinition(new ShipType()), |
| 41 | 41 | 'description' => 'The ships used by the faction', |
| 42 | 42 | 'args' => Connection::connectionArgs(), |
| 43 | - 'resolve' => function ($value = null, $args = [], $type = null) { |
|
| 44 | - return ArrayConnection::connectionFromArray(array_map(function ($id) { |
|
| 43 | + 'resolve' => function($value = null, $args = [], $type = null) { |
|
| 44 | + return ArrayConnection::connectionFromArray(array_map(function($id) { |
|
| 45 | 45 | return TestDataProvider::getShip($id); |
| 46 | 46 | }, $value['ships']), $args); |
| 47 | 47 | } |