Skip to content

Commit 5ed0e3a

Browse files
authored
Merge pull request #18 from Zheness/Zheness/skip_blob_type
Skip graphql column generation for BLOB type.
2 parents ac792bf + 602d5fd commit 5ed0e3a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/GraphQLTypeGenerator.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ private function generateFieldCode(AbstractBeanPropertyDescriptor $descriptor) :
270270
$type = $this->getType($descriptor);
271271

272272
if ($type === null) {
273-
return " // Field $getterName is ignored. Cannot represent a JSON field in GraphQL.";
273+
return " // Field $getterName is ignored. Cannot represent a JSON or BLOB field in GraphQL.";
274274
}
275275

276276
$code = <<<EOF
@@ -284,7 +284,6 @@ protected function {$getterName}Field() : Field
284284
return $thisVariableName;
285285
}
286286
287-
288287
EOF;
289288

290289
return $code;
@@ -300,8 +299,8 @@ private function getType(AbstractBeanPropertyDescriptor $descriptor) : ?string
300299

301300
$phpType = $descriptor->getPhpType();
302301
if ($descriptor instanceof ScalarBeanPropertyDescriptor) {
303-
if ($phpType === 'array') {
304-
// JSON type cannot be casted since GraphQL does not allow for untyped arrays.
302+
if ($phpType === 'array' || $phpType === 'resource') {
303+
// JSON and BLOB type cannot be casted since GraphQL does not allow for untyped arrays or BLOB.
305304
return null;
306305
}
307306

@@ -314,7 +313,7 @@ private function getType(AbstractBeanPropertyDescriptor $descriptor) : ?string
314313
];
315314

316315
if (!isset($map[$phpType])) {
317-
throw new GraphQLGeneratorNamespaceException("Cannot map PHP type '$phpType' to any known GraphQL type.");
316+
throw new GraphQLGeneratorNamespaceException("Cannot map PHP type '$phpType' to any known GraphQL type in table '{$descriptor->getTable()->getName()}' for column '{$descriptor->getColumnName()}'.");
318317
}
319318

320319
$newCode = 'new '.$map[$phpType].'()';

0 commit comments

Comments
 (0)