@@ -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 | ] |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | protected function executeMutation(Mutation $mutation, $currentLevelSchema) |
| 159 | 159 | { |
| 160 | - if (!$currentLevelSchema) throw new ConfigurationException('There is no mutation ' . $mutation->getName()); |
|
| 160 | + if (!$currentLevelSchema) throw new ConfigurationException('There is no mutation '.$mutation->getName()); |
|
| 161 | 161 | |
| 162 | 162 | if (!$this->resolveValidator->checkFieldExist($currentLevelSchema, $mutation)) { |
| 163 | 163 | return null; |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | } |
| 247 | 247 | } elseif ($field->getType()->getKind() == TypeMap::KIND_NON_NULL) { |
| 248 | 248 | if (!$field->getType()->isValidValue($preResolvedValue)) { |
| 249 | - $this->resolveValidator->addError(new ResolveException(sprintf('Cannot return null for non-nullable field %s', $astField->getName() . '.' . $field->getName()))); |
|
| 249 | + $this->resolveValidator->addError(new ResolveException(sprintf('Cannot return null for non-nullable field %s', $astField->getName().'.'.$field->getName()))); |
|
| 250 | 250 | } elseif (!$field->getType()->getNullableType()->isValidValue($preResolvedValue)) { |
| 251 | 251 | $this->resolveValidator->addError(new ResolveException(sprintf('Not valid value for %s field %s', $field->getType()->getNullableType()->getKind(), $field->getName()))); |
| 252 | 252 | $value = null; |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | protected function getPropertyValue($data, $path) |
| 358 | 358 | { |
| 359 | 359 | if (is_object($data)) { |
| 360 | - $getter = 'get' . $this->classify($path); |
|
| 360 | + $getter = 'get'.$this->classify($path); |
|
| 361 | 361 | |
| 362 | 362 | return is_callable([$data, $getter]) ? $data->$getter() : null; |
| 363 | 363 | } elseif (is_array($data)) { |
@@ -81,7 +81,9 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | public function processRequest($payload, $variables = []) |
| 83 | 83 | { |
| 84 | - if ($this->hasErrors()) return $this; |
|
| 84 | + if ($this->hasErrors()) { |
|
| 85 | + return $this; |
|
| 86 | + } |
|
| 85 | 87 | |
| 86 | 88 | $this->data = []; |
| 87 | 89 | |
@@ -157,7 +159,9 @@ discard block |
||
| 157 | 159 | */ |
| 158 | 160 | protected function executeMutation(Mutation $mutation, $currentLevelSchema) |
| 159 | 161 | { |
| 160 | - if (!$currentLevelSchema) throw new ConfigurationException('There is no mutation ' . $mutation->getName()); |
|
| 162 | + if (!$currentLevelSchema) { |
|
| 163 | + throw new ConfigurationException('There is no mutation ' . $mutation->getName()); |
|
| 164 | + } |
|
| 161 | 165 | |
| 162 | 166 | if (!$this->resolveValidator->checkFieldExist($currentLevelSchema, $mutation)) { |
| 163 | 167 | return null; |
@@ -21,7 +21,9 @@ |
||
| 21 | 21 | |
| 22 | 22 | public function buildArguments() |
| 23 | 23 | { |
| 24 | - if ($this->_isArgumentBuilt) return true; |
|
| 24 | + if ($this->_isArgumentBuilt) { |
|
| 25 | + return true; |
|
| 26 | + } |
|
| 25 | 27 | $sourceArguments = empty($this->data['args']) ? [] : $this->data['args']; |
| 26 | 28 | foreach ($sourceArguments as $argumentName => $argumentInfo) { |
| 27 | 29 | if ($argumentInfo instanceof InputField) { |