首页 > 解决方案 > 如何使用 KGraphQL 连接到托管在 AWS 上的 Graph QL 服务器

问题描述

我是图形 ql 的新手。我正在尝试使用 hhtp4k 库中的 Get 方法连接到托管在 AWS 上的 Graph QL 服务器。但是,我不断收到以下错误消息:

{“消息”:“内部服务器错误”}

不知道我做错了什么。相同的代码似乎适用于演示 apollo graphql 数据库。

package me.pagidas.graphql

import org.http4k.core.HttpHandler
import org.http4k.core.Method.GET
import org.http4k.core.Request
import org.http4k.core.Response
import org.http4k.core.Status.Companion.OK
import org.http4k.core.Uri
import org.http4k.lens.Query
import org.http4k.lens.string
import org.http4k.routing.bind
import org.http4k.routing.routes
import org.http4k.server.Jetty
import org.http4k.server.asServer
import org.http4k.client.ApacheClient

fun testApp1() {
    val http = ApacheClient()

    http(
        Request(GET, "aws-url/graphql")
            .query("query",
                """
                   query Feed {
                      getFeed{
                        nextBatch
                    }
                    }

            """.trimIndent()
            )
    ).apply {
        println("---------------------")
        println("---GET ALL WRITERS---")
        println("---------------------")
        println(bodyString())
    }
}

fun main() {
    testApp1()
}

标签: androidamazon-web-serviceskotlingraphql

解决方案


推荐阅读