Skip to content

Commit 9173368

Browse files
committed
Fixing issue with output ID and foreign keys
1 parent 8253fac commit 9173368

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/TdbmFluidColumnGraphqlOptions.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,18 @@ private function generateFieldAnnotation(): void
6363
if ($this->outputType !== null) {
6464
$outputType = $this->outputType;
6565
} elseif ($this->fluidColumn->getDbalColumn()->getType() === Type::getType(Type::GUID)) {
66-
$outputType = 'ID';
66+
// are we part of a foreign key or not?
67+
$fks = $this->tdbmFluidColumnOptions->then()->getDbalTable()->getForeignKeys();
68+
$isPartOfFk = false;
69+
foreach ($fks as $fk) {
70+
if (in_array($this->fluidColumn->getDbalColumn()->getName(), $fk->getLocalColumns(), true) === true) {
71+
$isPartOfFk = true;
72+
break;
73+
}
74+
}
75+
if ($isPartOfFk === false) {
76+
$outputType = 'ID';
77+
}
6778
} else {
6879
// If the column is the primary key, let's add an ID type
6980
$pk = $this->tdbmFluidColumnOptions->then()->getDbalTable()->getPrimaryKey();

0 commit comments

Comments
 (0)