| @@ 52-74 (lines=23) @@ | ||
| 49 | * @return \Youshido\GraphQL\Field\FieldInterface[] |
|
| 50 | * The list of fields. |
|
| 51 | */ |
|
| 52 | protected function buildFields(PluggableSchemaBuilderInterface $schemaBuilder) { |
|
| 53 | $arguments = []; |
|
| 54 | ||
| 55 | if ($this instanceof PluginInspectionInterface) { |
|
| 56 | $definition = $this->getPluginDefinition(); |
|
| 57 | ||
| 58 | foreach ($definition['fields'] as $name => $argument) { |
|
| 59 | $type = $this->buildFieldType($schemaBuilder, $argument); |
|
| 60 | $config = [ |
|
| 61 | 'name' => $name, |
|
| 62 | 'type' => $type, |
|
| 63 | ]; |
|
| 64 | ||
| 65 | if (is_array($argument) && isset($argument['default'])) { |
|
| 66 | $config['defaultValue'] = $argument['default']; |
|
| 67 | } |
|
| 68 | ||
| 69 | $arguments[$name] = new Field($config); |
|
| 70 | } |
|
| 71 | } |
|
| 72 | ||
| 73 | return $arguments; |
|
| 74 | } |
|
| 75 | ||
| 76 | /** |
|
| 77 | * Build the field type. |
|
| @@ 24-46 (lines=23) @@ | ||
| 21 | * @return \Youshido\GraphQL\Field\InputFieldInterface[] |
|
| 22 | * The list of arguments. |
|
| 23 | */ |
|
| 24 | protected function buildArguments(PluggableSchemaBuilderInterface $schemaBuilder) { |
|
| 25 | $arguments = []; |
|
| 26 | ||
| 27 | if ($this instanceof PluginInspectionInterface) { |
|
| 28 | $definition = $this->getPluginDefinition(); |
|
| 29 | ||
| 30 | foreach ($definition['arguments'] as $name => $argument) { |
|
| 31 | $type = $this->buildArgumentType($schemaBuilder, $argument); |
|
| 32 | $config = [ |
|
| 33 | 'name' => $name, |
|
| 34 | 'type' => $type, |
|
| 35 | ]; |
|
| 36 | ||
| 37 | if (is_array($argument) && isset($argument['default'])) { |
|
| 38 | $config['defaultValue'] = $argument['default']; |
|
| 39 | } |
|
| 40 | ||
| 41 | $arguments[$name] = new InputField($config); |
|
| 42 | } |
|
| 43 | } |
|
| 44 | ||
| 45 | return $arguments; |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * Build the argument type. |
|