Skip to content

Commit dba5eb0

Browse files
committed
fixed InputFields
1 parent f09720f commit dba5eb0

File tree

4 files changed

+12
-22
lines changed

4 files changed

+12
-22
lines changed

examples/02_blog_inline/index.php

-21
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,6 @@
1313
require_once __DIR__ . '/inline-schema.php';
1414
/** @var ObjectType $rootQueryType */
1515

16-
17-
//$rootQueryType = new ObjectType([
18-
// 'name' => 'RootQuery',
19-
// 'fields' => [
20-
// 'latestPost' => [
21-
// 'type' => 'Post',
22-
// 'fields' => [
23-
// 'title' => new StringType(),
24-
// 'summary' => new StringType(),
25-
// ],
26-
// 'resolve' => function() {
27-
// return [
28-
// 'title' => 'hello',
29-
// 'summary' => 'this is a post'
30-
// ];
31-
// }
32-
// ]
33-
// ]
34-
//]);
35-
36-
3716
$processor = new Processor();
3817
$processor->setSchema(new Schema([
3918
'query' => $rootQueryType

src/Introspection/InputValueListType.php

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ public function resolve($value = null, $args = [], $type = null)
2525
{
2626
if ($value instanceof Field) {
2727
/** @var $value Field */
28+
if ($value->getConfig()->hasArguments()) {
29+
return $value->getConfig()->getArguments();
30+
}
2831
$valueType = $value->getConfig()->getType();
2932
if ($valueType instanceof AbstractScalarType) {
3033
return [];

src/Introspection/Traits/TypeCollectorTrait.php

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Youshido\GraphQL\Type\AbstractType;
1111
use Youshido\GraphQL\Type\CompositeTypeInterface;
1212
use Youshido\GraphQL\Type\Config\Field\FieldConfig;
13+
use Youshido\GraphQL\Type\Object\AbstractObjectType;
1314
use Youshido\GraphQL\Type\TypeInterface;
1415
use Youshido\GraphQL\Type\TypeMap;
1516

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

3032
switch ($type->getKind()) {
3133
case TypeMap::KIND_INTERFACE:
@@ -107,6 +109,11 @@ private function checkAndInsertInterfaces($type)
107109
private function collectFieldsArgsTypes($type)
108110
{
109111
foreach ($type->getConfig()->getFields() as $field) {
112+
if ($field->getConfig()->getType() instanceof AbstractObjectType) {
113+
foreach($field->getConfig()->getArguments() as $argument) {
114+
$this->collectTypes($argument->getType());
115+
}
116+
}
110117
$this->collectTypes($field->getType());
111118
}
112119
foreach ($type->getConfig()->getArguments() as $field) {

src/Type/Config/Field/InputFieldConfig.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public function getRules()
2020
return [
2121
'name' => ['type' => TypeMap::TYPE_STRING, 'required' => true],
2222
'type' => ['type' => TypeMap::TYPE_ANY_INPUT, 'required' => true],
23+
'resolve' => ['type' => TypeMap::TYPE_FUNCTION],
2324
'required' => ['type' => TypeMap::TYPE_BOOLEAN],
2425
'default' => ['type' => TypeMap::TYPE_ANY],
2526
'description' => ['type' => TypeMap::TYPE_STRING],
@@ -31,4 +32,4 @@ public function getDefaultValue()
3132
return $this->get('default');
3233
}
3334

34-
}
35+
}

0 commit comments

Comments
 (0)