Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Result JSON cut off #308

Closed
Closed
@KuschL

Description

@KuschL

The JSON Response of my QueryResolver cuts off the text if I load emojis in the text-field. I think it's an encoding problem but I don't know how to solve it. I can recreate the issue with following code:

// Message.kt
@Document
data class Message(
    var text: String,
    var sender: User,
    var createdAt: Date = Date(),
    var chatId: String
) {
    @Id
    @NotNull
    lateinit var id: String
}
// MessageQueryResolver.kt
@Component
class ChatQueryResolver(
    private val chatRepository: ChatRepository,
    private val messageRepository: MessageRepository
) : GraphQLQueryResolver {

    fun getMessages(chatId: String, createdAt: Date?, size: Int?): List<Message>? {
        val chat = chatRepository.findById(chatId).orElseThrow { throw RuntimeException("Chat not found") }
    
        val pageable: Pageable = PageRequest.of(0, size ?: 50)
        return messageRepository.findAllByChatIdAndCreatedAtLessThanOrderByCreatedAtDesc(
            pageable,
            chatId,
            createdAt ?: Date()
        ).toList()
    }
}

If I query getMessages the result JSON is cut off, so it will be invalid:

{
  getMessages(chatId: "global", size:1) {
    id
    text
  }
}
"{\"data\":{\"getMessages\":[{\"id\":\"5dea59a33b59764933d133f6\",\"text\":\"this is an test with an emoji... 🤷‍♂"

I'm using the following versions of Spring Boot and GraphQL Libraries:

plugins {
    id("org.springframework.boot") version "2.2.1.RELEASE"
    id("io.spring.dependency-management") version "1.0.8.RELEASE"
    kotlin("jvm") version "1.3.50"
    kotlin("plugin.spring") version "1.3.50"
}
// ...
dependencies {
    implementation("io.reactivex.rxjava2:rxjava:2.2.3")
    implementation("org.springframework.boot:spring-boot-starter-web")
    implementation("org.springframework.boot:spring-boot-starter-data-mongodb-reactive")
    implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
    implementation("org.jetbrains.kotlin:kotlin-reflect")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
    implementation("com.graphql-java-kickstart:graphql-spring-boot-starter:6.0.0")
    implementation("com.graphql-java-kickstart:graphiql-spring-boot-starter:6.0.0")
// ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions