@@ -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 | |
@@ -21,4 +21,4 @@ discard block |
||
21 | 21 | $payload = 'mutation { createPost(author: "Alex", post: {title: "Hey, this is my new post", summary: "my post" }) { title } }'; |
22 | 22 | |
23 | 23 | $processor->processRequest($payload); |
24 | -echo json_encode($processor->getResponseData()) . "\n"; |
|
24 | +echo json_encode($processor->getResponseData())."\n"; |
@@ -47,7 +47,9 @@ |
||
47 | 47 | // code for creating a new post goes here |
48 | 48 | // we simple use our DataProvider for now |
49 | 49 | $post = DataProvider::getPost(10); |
50 | - if (!empty($args['post']['title'])) $post['title'] = $args['post']['title']; |
|
50 | + if (!empty($args['post']['title'])) { |
|
51 | + $post['title'] = $args['post']['title']; |
|
52 | + } |
|
51 | 53 | return $post; |
52 | 54 | } |
53 | 55 | ] |
@@ -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); |
@@ -45,6 +45,9 @@ |
||
45 | 45 | { |
46 | 46 | } |
47 | 47 | |
48 | + /** |
|
49 | + * @param string $name |
|
50 | + */ |
|
48 | 51 | public function addQuery($name, AbstractObjectType $query) |
49 | 52 | { |
50 | 53 | $this->getQueryType()->getConfig()->addField($name, $query); |
@@ -18,7 +18,9 @@ |
||
18 | 18 | |
19 | 19 | public function buildArguments() |
20 | 20 | { |
21 | - if ($this->_isArgumentsBuilt) return true; |
|
21 | + if ($this->_isArgumentsBuilt) { |
|
22 | + return true; |
|
23 | + } |
|
22 | 24 | |
23 | 25 | if (!empty($this->data['args'])) { |
24 | 26 | $this->addArguments($this->data['args']); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | |
95 | 95 | /** |
96 | - * @param $name |
|
96 | + * @param string $name |
|
97 | 97 | * |
98 | 98 | * @return Field |
99 | 99 | */ |
@@ -125,6 +125,9 @@ discard block |
||
125 | 125 | return $this->fields; |
126 | 126 | } |
127 | 127 | |
128 | + /** |
|
129 | + * @param string $name |
|
130 | + */ |
|
128 | 131 | public function removeField($name) |
129 | 132 | { |
130 | 133 | if ($this->hasField($name)) { |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
63 | - * @param mixed $name |
|
63 | + * @param string $name |
|
64 | 64 | */ |
65 | 65 | public function setName($name) |
66 | 66 | { |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | - * @param mixed $model |
|
79 | + * @param string $model |
|
80 | 80 | */ |
81 | 81 | public function setModel($model) |
82 | 82 | { |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
87 | - * @return Field[]|Query[] |
|
87 | + * @return Query[] |
|
88 | 88 | */ |
89 | 89 | public function getFields() |
90 | 90 | { |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
95 | - * @param Field[]|Query[] $fields |
|
95 | + * @param Field[] $fields |
|
96 | 96 | */ |
97 | 97 | public function setFields($fields) |
98 | 98 | { |
@@ -74,7 +74,7 @@ |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
77 | - * @return Field[]|Query[]|FragmentInterface[] |
|
77 | + * @return Query[] |
|
78 | 78 | */ |
79 | 79 | public function getFields() |
80 | 80 | { |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
31 | - * @return Field[]|Query[] |
|
31 | + * @return Field[] |
|
32 | 32 | */ |
33 | 33 | public function getFields() |
34 | 34 | { |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
39 | - * @param Field[]|Query[] $fields |
|
39 | + * @param Field[] $fields |
|
40 | 40 | */ |
41 | 41 | public function setFields($fields) |
42 | 42 | { |
@@ -45,6 +45,9 @@ |
||
45 | 45 | $this->config = new InterfaceTypeConfig($config, $this); |
46 | 46 | } |
47 | 47 | |
48 | + /** |
|
49 | + * @return AbstractType |
|
50 | + */ |
|
48 | 51 | abstract public function resolveType($object); |
49 | 52 | |
50 | 53 | /** |
@@ -59,7 +59,9 @@ |
||
59 | 59 | { |
60 | 60 | if ($value instanceof AbstractObjectType) { |
61 | 61 | foreach($value->getInterfaces() as $interface) { |
62 | - if ($interface instanceof $this) return true; |
|
62 | + if ($interface instanceof $this) { |
|
63 | + return true; |
|
64 | + } |
|
63 | 65 | } |
64 | 66 | } |
65 | 67 | return false; |
@@ -25,6 +25,9 @@ |
||
25 | 25 | { |
26 | 26 | } |
27 | 27 | |
28 | + /** |
|
29 | + * @param \Youshido\GraphQL\Type\Object\ObjectType $object |
|
30 | + */ |
|
28 | 31 | public function resolveType($object) |
29 | 32 | { |
30 | 33 | return $this->getConfig()->resolveType($object); |