diff --git a/src/Rebing/GraphQL/Support/SelectFields.php b/src/Rebing/GraphQL/Support/SelectFields.php index f1c480fc..1380c1c6 100644 --- a/src/Rebing/GraphQL/Support/SelectFields.php +++ b/src/Rebing/GraphQL/Support/SelectFields.php @@ -168,6 +168,8 @@ protected static function handleFields(array $requestedFields, $parentType, arra $foreignKey = $relation->getQualifiedForeignKeyName(); } + $segments = explode('.', $foreignKey); + $foreignKey = end($segments); $foreignKey = $parentTable ? ($parentTable . '.' . $foreignKey) : $foreignKey; if(is_a($relation, MorphTo::class)) diff --git a/src/Rebing/GraphQL/Support/Type.php b/src/Rebing/GraphQL/Support/Type.php index aac3a2d0..5fb0bd08 100644 --- a/src/Rebing/GraphQL/Support/Type.php +++ b/src/Rebing/GraphQL/Support/Type.php @@ -123,7 +123,8 @@ public function toType() { return new InputObjectType($this->toArray()); } - if ($this->enumObject) { + if ($this->enumObject) + { return new EnumType($this->toArray()); } return new ObjectType($this->toArray());