Skip to content

Commit b13d490

Browse files
kylekatarnlsMikk Mihkel Nurges
authored andcommitted
Take only foreign key column to avoid duplicate table prefix (#175)
1 parent 3222576 commit b13d490

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Rebing/GraphQL/Support/SelectFields.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ protected static function handleFields(array $requestedFields, $parentType, arra
168168
$foreignKey = $relation->getQualifiedForeignKeyName();
169169
}
170170

171+
$segments = explode('.', $foreignKey);
172+
$foreignKey = end($segments);
171173
$foreignKey = $parentTable ? ($parentTable . '.' . $foreignKey) : $foreignKey;
172174

173175
if(is_a($relation, MorphTo::class))

src/Rebing/GraphQL/Support/Type.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ public function toType()
123123
{
124124
return new InputObjectType($this->toArray());
125125
}
126-
if ($this->enumObject) {
126+
if ($this->enumObject)
127+
{
127128
return new EnumType($this->toArray());
128129
}
129130
return new ObjectType($this->toArray());

0 commit comments

Comments
 (0)