src/GraphQl/Type/SchemaBuilder.php
private function convertType(Type $type, bool $input, ?string $queryName, ?string $mutationName, int $depth = 0)
    {
        switch ($builtinType = $type->getBuiltinType()) {
            case Type::BUILTIN_TYPE_BOOL:
                $graphqlType = GraphQLType::boolean();
                break;
            case Type::BUILTIN_TYPE_INT:
                $graphqlType = GraphQLType::int();
                break;
            case Type::BUILTIN_TYPE_FLOAT:
                $graphqlType = GraphQLType::float();
                break;
            case Type::BUILTIN_TYPE_STRING:
                $graphqlType = GraphQLType::string();
                break;
            case Type::BUILTIN_TYPE_ARRAY:
            case Type::BUILTIN_TYPE_ITERABLE:
                $graphqlType = $this->graphqlTypes['Iterable'];
                break;
            case Type::BUILTIN_TYPE_OBJECT:
                if (($input && $depth > 0) || is_a($type->getClassName(), \DateTimeInterface::class, true)) {
                    $graphqlType = GraphQLType::string();
                    break;
                }

                $resourceClass = $this->isCollection($type) && ($collectionValueType = $type->getCollectionValueType()) ? $collectionValueType->getClassName() : $type->getClassName();
                if (null === $resourceClass) {
                    return null;
                }

                try {
                    $resourceMetadata = $this->resourceMetadataFactory->create($resourceClass);
                    if ([] === $resourceMetadata->getGraphql() ?? []) {
                        return null;
                    }
                } catch (ResourceClassNotFoundException $e) {
                    // Skip objects that are not resources for now
                    return null;
                }

                $graphqlType = $this->getResourceObjectType($resourceClass, $resourceMetadata, $input, $queryName, $mutationName, false, $depth);
                break;
            default:
                throw new InvalidTypeException(sprintf('The type "%s" is not supported.', $builtinType));
        }

        if ($this->isCollection($type)) {
            return $this->paginationEnabled && !$input ? $this->getResourcePaginatedCollectionType($graphqlType) : GraphQLType::listOf($graphqlType);
        }

        return $type->isNullable() || (null !== $mutationName && 'update' === $mutationName) ? $graphqlType : GraphQLType::nonNull($graphqlType);
    }
private function convertType(Type $type, bool $input, ?string $queryName, ?string $mutationName, int $depth = 0)
    {
        switch ($builtinType = $type->getBuiltinType()) {
            case Type::BUILTIN_TYPE_BOOL:
                $graphqlType = GraphQLType::boolean();
                break;
            case Type::BUILTIN_TYPE_INT:
                $graphqlType = GraphQLType::int();
                break;
            case Type::BUILTIN_TYPE_FLOAT:
                $graphqlType = GraphQLType::float();
                break;
            case Type::BUILTIN_TYPE_STRING:
                $graphqlType = GraphQLType::string();
                break;
            case Type::BUILTIN_TYPE_ARRAY:
            case Type::BUILTIN_TYPE_ITERABLE:
                $graphqlType = $this->graphqlTypes['Iterable'];
                break;
            case Type::BUILTIN_TYPE_OBJECT:
                if (($input && $depth > 0) || is_a($type->getClassName(), \DateTimeInterface::class, true)) {
                    $graphqlType = GraphQLType::string();
                    break;
                }

                $resourceClass = $this->isCollection($type) && ($collectionValueType = $type->getCollectionValueType()) ? $collectionValueType->getClassName() : $type->getClassName();
                if (null === $resourceClass) {
                    return null;
                }

                try {
                    $resourceMetadata = $this->resourceMetadataFactory->create($resourceClass);
                    if ([] === $resourceMetadata->getGraphql() ?? []) {
                        return null;
                    }
                } catch (ResourceClassNotFoundException $e) {
                    // Skip objects that are not resources for now
                    return null;
                }

                $graphqlType = $this->getResourceObjectType($resourceClass, $resourceMetadata, $input, $queryName, $mutationName, false, $depth);
                break;
            default:
                throw new InvalidTypeException(sprintf('The type "%s" is not supported.', $builtinType));
        }

        if ($this->isCollection($type)) {
            return $this->paginationEnabled && !$input ? $this->getResourcePaginatedCollectionType($graphqlType) : GraphQLType::listOf($graphqlType);
        }

        return $type->isNullable() || (null !== $mutationName && 'update' === $mutationName) ? $graphqlType : GraphQLType::nonNull($graphqlType);
    }
private function convertType ( Type $ type , bool $ input , ? string $ queryName , ? string $ mutationName , int $ depth = 0 ) { switch ( $ builtinType = $ type -> getBuiltinType ( ) ) { case Type :: BUILTIN_TYPE_BOOL : $ graphqlType = GraphQLType :: boolean ( ) ; break ; case Type :: BUILTIN_TYPE_INT : $ graphqlType = GraphQLType :: int ( ) ; break ; case Type :: BUILTIN_TYPE_FLOAT : $ graphqlType = GraphQLType :: float ( ) ; break ; case Type :: BUILTIN_TYPE_STRING : $ graphqlType = GraphQLType :: string ( ) ; break ; case Type :: BUILTIN_TYPE_ARRAY : case Type :: BUILTIN_TYPE_ITERABLE : $ graphqlType = $ this -> graphqlTypes [ 'Iterable' ] ; break ; case Type :: BUILTIN_TYPE_OBJECT : if ( ( $ input && $ depth > 0 ) || is_a ( $ type -> getClassName ( ) , \ DateTimeInterface :: class , true ) ) { $ graphqlType = GraphQLType :: string ( ) ; break ; } $ resourceClass = $ this -> isCollection ( $ type ) && ( $ collectionValueType = $ type -> getCollectionValueType ( ) ) ? $ collectionValueType -> getClassName ( ) : $ type -> getClassName ( ) ; if ( null === $ resourceClass ) { return null ; } try { $ resourceMetadata = $ this -> resourceMetadataFactory -> create ( $ resourceClass ) ; if ( [ ] === $ resourceMetadata -> getGraphql ( ) ?? [ ] ) { return null ; } } catch ( ResourceClassNotFoundException $ e ) { // Skip objects that are not resources for now return null ; } $ graphqlType = $ this -> getResourceObjectType ( $ resourceClass , $ resourceMetadata , $ input , $ queryName , $ mutationName , false , $ depth ) ; break ; default : throw new InvalidTypeException ( sprintf ( 'The type "%s" is not supported.' , $ builtinType ) ) ; } if ( $ this -> isCollection ( $ type ) ) { return $ this -> paginationEnabled && ! $ input ? $ this -> getResourcePaginatedCollectionType ( $ graphqlType ) : GraphQLType :: listOf ( $ graphqlType ) ; } return $ type -> isNullable ( ) || ( null !== $ mutationName && 'update' === $ mutationName ) ? $ graphqlType : GraphQLType :: nonNull ( $ graphqlType ) ; }
Converts a built-in type to its GraphQL equivalent.

@throws InvalidTypeException
Converts a built - in type to its GraphQL equivalent .