diff --git a/src/InterfaceTypeCreator.php b/src/InterfaceTypeCreator.php new file mode 100644 index 000000000..4a6e05c14 --- /dev/null +++ b/src/InterfaceTypeCreator.php @@ -0,0 +1,47 @@ +getTypeResolver(); + if(isset($resolver)) + { + $attributes['resolveType'] = $resolver; + } + + return $attributes; + } + + public function toType() + { + return new BaseInterfaceType($this->toArray()); + } + +} diff --git a/src/TypeCreator.php b/src/TypeCreator.php index 7317f643a..ed4da3197 100644 --- a/src/TypeCreator.php +++ b/src/TypeCreator.php @@ -53,6 +53,14 @@ public function fields() return []; } + /** + * @return array + */ + public function interfaces() + { + return []; + } + /** * Returns field structure with field resolvers added. * @@ -106,7 +114,9 @@ public function toArray() public function getAttributes() { - return array_merge( + $interfaces = $this->interfaces(); + + $attributes = array_merge( $this->attributes(), [ 'fields' => function () { @@ -114,6 +124,12 @@ public function getAttributes() }, ] ); + + if(sizeof($interfaces)) { + $attributes['interfaces'] = $interfaces; + } + + return $attributes; } /**