| @@ 17-60 (lines=44) @@ | ||
| 14 | use Youshido\GraphQL\Type\Config\TypeConfigInterface; |
|
| 15 | use Youshido\GraphQL\Type\TypeMap; |
|
| 16 | ||
| 17 | abstract class AbstractInterfaceType extends AbstractType |
|
| 18 | { |
|
| 19 | ||
| 20 | /** |
|
| 21 | * ObjectType constructor. |
|
| 22 | * @param $config |
|
| 23 | */ |
|
| 24 | public function __construct($config = []) |
|
| 25 | { |
|
| 26 | if (empty($config)) { |
|
| 27 | $config['name'] = $this->getName(); |
|
| 28 | } |
|
| 29 | ||
| 30 | $this->config = new InterfaceTypeConfig($config, $this); |
|
| 31 | } |
|
| 32 | ||
| 33 | abstract protected function build(TypeConfigInterface $config); |
|
| 34 | ||
| 35 | public function resolveType($object) |
|
| 36 | { |
|
| 37 | return $object; |
|
| 38 | } |
|
| 39 | ||
| 40 | public function checkBuild() |
|
| 41 | { |
|
| 42 | if (!$this->isBuild) { |
|
| 43 | $this->isBuild = true; |
|
| 44 | $this->build($this->config); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||
| 48 | abstract public function getName(); |
|
| 49 | ||
| 50 | public function getKind() |
|
| 51 | { |
|
| 52 | return TypeMap::KIND_INTERFACE; |
|
| 53 | } |
|
| 54 | ||
| 55 | public function isValidValue($value) |
|
| 56 | { |
|
| 57 | return true; |
|
| 58 | } |
|
| 59 | ||
| 60 | } |
|
| @@ 17-68 (lines=52) @@ | ||
| 14 | use Youshido\GraphQL\Type\Config\TypeConfigInterface; |
|
| 15 | use Youshido\GraphQL\Type\TypeMap; |
|
| 16 | ||
| 17 | abstract class AbstractUnionType extends AbstractType |
|
| 18 | { |
|
| 19 | ||
| 20 | ||
| 21 | /** |
|
| 22 | * ObjectType constructor. |
|
| 23 | * @param $config |
|
| 24 | */ |
|
| 25 | public function __construct($config = []) |
|
| 26 | { |
|
| 27 | if (empty($config)) { |
|
| 28 | $config['name'] = $this->getName(); |
|
| 29 | $config['types'] = $this->getTypes(); |
|
| 30 | } |
|
| 31 | ||
| 32 | $this->config = new UnionTypeConfig($config, $this); |
|
| 33 | } |
|
| 34 | ||
| 35 | abstract public function getName(); |
|
| 36 | ||
| 37 | abstract public function resolveType($object); |
|
| 38 | ||
| 39 | abstract public function getTypes(); |
|
| 40 | ||
| 41 | public function checkBuild() |
|
| 42 | { |
|
| 43 | if (!$this->isBuild) { |
|
| 44 | $this->isBuild = true; |
|
| 45 | $this->build($this->config); |
|
| 46 | } |
|
| 47 | } |
|
| 48 | ||
| 49 | protected function build(TypeConfigInterface $config) |
|
| 50 | { |
|
| 51 | ||
| 52 | } |
|
| 53 | ||
| 54 | public function resolve($value = null, $args = []) { |
|
| 55 | ||
| 56 | } |
|
| 57 | ||
| 58 | public function getKind() |
|
| 59 | { |
|
| 60 | return TypeMap::KIND_UNION; |
|
| 61 | } |
|
| 62 | ||
| 63 | public function isValidValue($value) |
|
| 64 | { |
|
| 65 | return true; |
|
| 66 | } |
|
| 67 | ||
| 68 | } |
|