File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -252,6 +252,10 @@ private function generateFieldCode(AbstractBeanPropertyDescriptor $descriptor) :
252252
253253 $ type = $ this ->getType ($ descriptor );
254254
255+ if ($ type === null ) {
256+ return " // Field $ getterName is ignored. Cannot represent a JSON field in GraphQL. " ;
257+ }
258+
255259 $ code = <<<EOF
256260 private $ variableName;
257261
@@ -269,7 +273,7 @@ protected function {$getterName}Field() : Field
269273 return $ code ;
270274 }
271275
272- private function getType (AbstractBeanPropertyDescriptor $ descriptor )
276+ private function getType (AbstractBeanPropertyDescriptor $ descriptor ) : ? string
273277 {
274278 // FIXME: can there be several primary key? If yes, we might need to fix this.
275279 // Also, primary key should be named "ID"
@@ -279,9 +283,12 @@ private function getType(AbstractBeanPropertyDescriptor $descriptor)
279283
280284 $ phpType = $ descriptor ->getPhpType ();
281285 if ($ descriptor instanceof ScalarBeanPropertyDescriptor) {
286+ if ($ phpType === 'array ' ) {
287+ // JSON type cannot be casted since GraphQL does not allow for untyped arrays.
288+ return null ;
289+ }
290+
282291 $ map = [
283- // TODO: how to handle JSON properties???
284- //'array' => StringT,
285292 'string ' => '\\' .StringType::class,
286293 'bool ' => '\\' .BooleanType::class,
287294 '\DateTimeImmutable ' => '\\' .DateTimeType::class,
You can’t perform that action at this time.
0 commit comments