Skip to content

Commit

Permalink
fixed InputFields
Browse files Browse the repository at this point in the history
  • Loading branch information
viniychuk committed May 6, 2016
1 parent f09720f commit dba5eb0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 22 deletions.
21 changes: 0 additions & 21 deletions examples/02_blog_inline/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,6 @@
require_once __DIR__ . '/inline-schema.php';
/** @var ObjectType $rootQueryType */


//$rootQueryType = new ObjectType([
// 'name' => 'RootQuery',
// 'fields' => [
// 'latestPost' => [
// 'type' => 'Post',
// 'fields' => [
// 'title' => new StringType(),
// 'summary' => new StringType(),
// ],
// 'resolve' => function() {
// return [
// 'title' => 'hello',
// 'summary' => 'this is a post'
// ];
// }
// ]
// ]
//]);


$processor = new Processor();
$processor->setSchema(new Schema([
'query' => $rootQueryType
Expand Down
3 changes: 3 additions & 0 deletions src/Introspection/InputValueListType.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public function resolve($value = null, $args = [], $type = null)
{
if ($value instanceof Field) {
/** @var $value Field */
if ($value->getConfig()->hasArguments()) {
return $value->getConfig()->getArguments();
}
$valueType = $value->getConfig()->getType();
if ($valueType instanceof AbstractScalarType) {
return [];
Expand Down
7 changes: 7 additions & 0 deletions src/Introspection/Traits/TypeCollectorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Youshido\GraphQL\Type\AbstractType;
use Youshido\GraphQL\Type\CompositeTypeInterface;
use Youshido\GraphQL\Type\Config\Field\FieldConfig;
use Youshido\GraphQL\Type\Object\AbstractObjectType;
use Youshido\GraphQL\Type\TypeInterface;
use Youshido\GraphQL\Type\TypeMap;

Expand All @@ -26,6 +27,7 @@ protected function collectTypes($type)
if (!$type) {
return;
}
if (is_object($type) && array_key_exists($type->getName(), $this->types)) return;

switch ($type->getKind()) {
case TypeMap::KIND_INTERFACE:
Expand Down Expand Up @@ -107,6 +109,11 @@ private function checkAndInsertInterfaces($type)
private function collectFieldsArgsTypes($type)
{
foreach ($type->getConfig()->getFields() as $field) {
if ($field->getConfig()->getType() instanceof AbstractObjectType) {
foreach($field->getConfig()->getArguments() as $argument) {
$this->collectTypes($argument->getType());
}
}
$this->collectTypes($field->getType());
}
foreach ($type->getConfig()->getArguments() as $field) {
Expand Down
3 changes: 2 additions & 1 deletion src/Type/Config/Field/InputFieldConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function getRules()
return [
'name' => ['type' => TypeMap::TYPE_STRING, 'required' => true],
'type' => ['type' => TypeMap::TYPE_ANY_INPUT, 'required' => true],
'resolve' => ['type' => TypeMap::TYPE_FUNCTION],
'required' => ['type' => TypeMap::TYPE_BOOLEAN],
'default' => ['type' => TypeMap::TYPE_ANY],
'description' => ['type' => TypeMap::TYPE_STRING],
Expand All @@ -31,4 +32,4 @@ public function getDefaultValue()
return $this->get('default');
}

}
}

0 comments on commit dba5eb0

Please sign in to comment.