@@ -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 | |
@@ -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); |
@@ -22,10 +22,10 @@ |
||
| 22 | 22 | public function __construct($config = []) |
| 23 | 23 | { |
| 24 | 24 | if (!array_key_exists('query', $config)) { |
| 25 | - $config['query'] = new ObjectType(['name' => $this->getName() . 'Query']); |
|
| 25 | + $config['query'] = new ObjectType(['name' => $this->getName().'Query']); |
|
| 26 | 26 | } |
| 27 | 27 | if (!array_key_exists('mutation', $config)) { |
| 28 | - $config['mutation'] = new ObjectType(['name' => $this->getName() . 'Mutation']); |
|
| 28 | + $config['mutation'] = new ObjectType(['name' => $this->getName().'Mutation']); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | $this->config = new SchemaConfig($config, $this); |
@@ -353,6 +353,9 @@ discard block |
||
| 353 | 353 | throw new \Exception(sprintf('Property "%s" not found in resolve result', $astField->getName())); |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | + /** |
|
| 357 | + * @param string $path |
|
| 358 | + */ |
|
| 356 | 359 | protected function getPropertyValue($data, $path) |
| 357 | 360 | { |
| 358 | 361 | if (is_object($data)) { |
@@ -398,8 +401,8 @@ discard block |
||
| 398 | 401 | } |
| 399 | 402 | |
| 400 | 403 | /** |
| 401 | - * @param $field Field |
|
| 402 | - * @param $query Query |
|
| 404 | + * @param Field $field Field |
|
| 405 | + * @param Query $query Query |
|
| 403 | 406 | * |
| 404 | 407 | * @return array |
| 405 | 408 | */ |
@@ -418,7 +421,7 @@ discard block |
||
| 418 | 421 | } |
| 419 | 422 | |
| 420 | 423 | /** |
| 421 | - * @param $query Query |
|
| 424 | + * @param Query $query Query |
|
| 422 | 425 | * @param $queryType ObjectType|TypeInterface|Field |
| 423 | 426 | * @param $resolvedValue mixed |
| 424 | 427 | * @param $value array |
@@ -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; |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | } elseif ($field->getType()->getKind() == TypeMap::KIND_NON_NULL) { |
| 247 | 247 | if (!$field->getType()->isValidValue($preResolvedValue)) { |
| 248 | - $this->resolveValidator->addError(new ResolveException(sprintf('Cannot return null for non-nullable field %s', $astField->getName() . '.' . $field->getName()))); |
|
| 248 | + $this->resolveValidator->addError(new ResolveException(sprintf('Cannot return null for non-nullable field %s', $astField->getName().'.'.$field->getName()))); |
|
| 249 | 249 | } elseif (!$field->getType()->getNullableType()->isValidValue($preResolvedValue)) { |
| 250 | 250 | $this->resolveValidator->addError(new ResolveException(sprintf('Not valid value for %s field %s', $field->getType()->getNullableType()->getKind(), $field->getName()))); |
| 251 | 251 | $value = null; |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | protected function getPropertyValue($data, $path) |
| 357 | 357 | { |
| 358 | 358 | if (is_object($data)) { |
| 359 | - $getter = 'get' . $this->classify($path); |
|
| 359 | + $getter = 'get'.$this->classify($path); |
|
| 360 | 360 | |
| 361 | 361 | return is_callable([$data, $getter]) ? $data->$getter() : null; |
| 362 | 362 | } elseif (is_array($data)) { |
@@ -55,6 +55,9 @@ |
||
| 55 | 55 | return $this; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | + /** |
|
| 59 | + * @param AbstractObjectType $value |
|
| 60 | + */ |
|
| 58 | 61 | public function isValidValue($value) |
| 59 | 62 | { |
| 60 | 63 | if ($value instanceof AbstractObjectType) { |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | public function isValidValue($value) |
| 59 | 59 | { |
| 60 | 60 | if ($value instanceof AbstractObjectType) { |
| 61 | - foreach($value->getInterfaces() as $interface) { |
|
| 61 | + foreach ($value->getInterfaces() as $interface) { |
|
| 62 | 62 | if ($interface instanceof $this) return true; |
| 63 | 63 | } |
| 64 | 64 | } |
@@ -51,7 +51,8 @@ |
||
| 51 | 51 | /** |
| 52 | 52 | * @param Field $intField |
| 53 | 53 | * @param Field $objField |
| 54 | - * @return bool |
|
| 54 | + * @param \Youshido\GraphQL\Type\Object\AbstractInterfaceType $interface |
|
| 55 | + * @return boolean|null |
|
| 55 | 56 | * @throws ConfigurationException |
| 56 | 57 | */ |
| 57 | 58 | protected function assertFieldsIdentical($intField, $objField, $interface) |
@@ -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 | |