private static function guessType(string $namespace, array $annotations)
    {
        $columnAnnotation = self::getFirstAnnotationMatching($annotations, 'Doctrine\ORM\Mapping\Column');
        if ($columnAnnotation) {
            $type = self::resolveTypeFromDoctrineType($columnAnnotation->type);
            $nullable = $columnAnnotation->nullable;
            if ($type) {
                return $nullable ? $type : \sprintf('%s!', $type);
            } else {
                throw new \Exception(\sprintf('Unable to auto-guess GraphQL type from Doctrine type "%s"', $columnAnnotation->type));
            }
        }

        $associationAnnotations = [
            'Doctrine\ORM\Mapping\OneToMany' => true,
            'Doctrine\ORM\Mapping\OneToOne' => false,
            'Doctrine\ORM\Mapping\ManyToMany' => true,
            'Doctrine\ORM\Mapping\ManyToOne' => false,
        ];

        $associationAnnotation = self::getFirstAnnotationMatching($annotations, \array_keys($associationAnnotations));
        if ($associationAnnotation) {
            $target = self::fullyQualifiedClassName($associationAnnotation->targetEntity, $namespace);
            $type = self::resolveTypeFromClass($target, ['type']);

            if ($type) {
                $isMultiple = $associationAnnotations[\get_class($associationAnnotation)];
                if ($isMultiple) {
                    return \sprintf('[%s]!', $type);
                } else {
                    $isNullable = false;
                    $joinColumn = self::getFirstAnnotationMatching($annotations, 'Doctrine\ORM\Mapping\JoinColumn');
                    if ($joinColumn) {
                        $isNullable = $joinColumn->nullable;
                    }

                    return \sprintf('%s%s', $type, $isNullable ? '' : '!');
                }
            } else {
                throw new \Exception(\sprintf('Unable to auto-guess GraphQL type from Doctrine target class "%s" (check if the target class is a GraphQL type itself (with a @GQL\Type annotation).', $target));
            }
        }

        throw new InvalidArgumentException(\sprintf('No Doctrine ORM annotation found.'));
    }
private static function guessType(string $namespace, array $annotations)
    {
        $columnAnnotation = self::getFirstAnnotationMatching($annotations, 'Doctrine\ORM\Mapping\Column');
        if ($columnAnnotation) {
            $type = self::resolveTypeFromDoctrineType($columnAnnotation->type);
            $nullable = $columnAnnotation->nullable;
            if ($type) {
                return $nullable ? $type : \sprintf('%s!', $type);
            } else {
                throw new \Exception(\sprintf('Unable to auto-guess GraphQL type from Doctrine type "%s"', $columnAnnotation->type));
            }
        }

        $associationAnnotations = [
            'Doctrine\ORM\Mapping\OneToMany' => true,
            'Doctrine\ORM\Mapping\OneToOne' => false,
            'Doctrine\ORM\Mapping\ManyToMany' => true,
            'Doctrine\ORM\Mapping\ManyToOne' => false,
        ];

        $associationAnnotation = self::getFirstAnnotationMatching($annotations, \array_keys($associationAnnotations));
        if ($associationAnnotation) {
            $target = self::fullyQualifiedClassName($associationAnnotation->targetEntity, $namespace);
            $type = self::resolveTypeFromClass($target, ['type']);

            if ($type) {
                $isMultiple = $associationAnnotations[\get_class($associationAnnotation)];
                if ($isMultiple) {
                    return \sprintf('[%s]!', $type);
                } else {
                    $isNullable = false;
                    $joinColumn = self::getFirstAnnotationMatching($annotations, 'Doctrine\ORM\Mapping\JoinColumn');
                    if ($joinColumn) {
                        $isNullable = $joinColumn->nullable;
                    }

                    return \sprintf('%s%s', $type, $isNullable ? '' : '!');
                }
            } else {
                throw new \Exception(\sprintf('Unable to auto-guess GraphQL type from Doctrine target class "%s" (check if the target class is a GraphQL type itself (with a @GQL\Type annotation).', $target));
            }
        }

        throw new InvalidArgumentException(\sprintf('No Doctrine ORM annotation found.'));
    }
private static function guessType ( string $ namespace , array $ annotations ) { $ columnAnnotation = self :: getFirstAnnotationMatching ( $ annotations , 'Doctrine\ORM\Mapping\Column' ) ; if ( $ columnAnnotation ) { $ type = self :: resolveTypeFromDoctrineType ( $ columnAnnotation -> type ) ; $ nullable = $ columnAnnotation -> nullable ; if ( $ type ) { return $ nullable ? $ type : \ sprintf ( '%s!' , $ type ) ; } else { throw new \ Exception ( \ sprintf ( 'Unable to auto-guess GraphQL type from Doctrine type "%s"' , $ columnAnnotation -> type ) ) ; } } $ associationAnnotations = [ 'Doctrine\ORM\Mapping\OneToMany' => true , 'Doctrine\ORM\Mapping\OneToOne' => false , 'Doctrine\ORM\Mapping\ManyToMany' => true , 'Doctrine\ORM\Mapping\ManyToOne' => false , ] ; $ associationAnnotation = self :: getFirstAnnotationMatching ( $ annotations , \ array_keys ( $ associationAnnotations ) ) ; if ( $ associationAnnotation ) { $ target = self :: fullyQualifiedClassName ( $ associationAnnotation -> targetEntity , $ namespace ) ; $ type = self :: resolveTypeFromClass ( $ target , [ 'type' ] ) ; if ( $ type ) { $ isMultiple = $ associationAnnotations [ \ get_class ( $ associationAnnotation ) ] ; if ( $ isMultiple ) { return \ sprintf ( '[%s]!' , $ type ) ; } else { $ isNullable = false ; $ joinColumn = self :: getFirstAnnotationMatching ( $ annotations , 'Doctrine\ORM\Mapping\JoinColumn' ) ; if ( $ joinColumn ) { $ isNullable = $ joinColumn -> nullable ; } return \ sprintf ( '%s%s' , $ type , $ isNullable ? '' : '!' ) ; } } else { throw new \ Exception ( \ sprintf ( 'Unable to auto-guess GraphQL type from Doctrine target class "%s" (check if the target class is a GraphQL type itself (with a @GQL\Type annotation).' , $ target ) ) ; } } throw new InvalidArgumentException ( \ sprintf ( 'No Doctrine ORM annotation found.' ) ) ; }
Try to guess a field type base on is annotations.

@param string $namespace
@param array  $annotations

@return string|false
Try to guess a field type base on is annotations .