使用 apolloclient 的 Graphql 查询结果 "Unexpected enum for a scalar" in android

Graphql query results in "Unexpected enum for a scalar" in android using apolloclient

我正在尝试使用带有 ApolloClient 的 Graphql 从 API 获取一些数据。但结果是 "Unexpected enum for a scalar"。请帮我解决错误。下面是我的代码。

ItemsQuery.graphql

query fetchCategoryItems($input : String!) {
__typename
items(where: {categoryUuid: {_eq: input}}) {
    categoryUuid
    description
    image
    name
    ..... // some more items
}

}

Activity代码。

val client = ApolloClientInstance.getInstance()
val categoryId = "random_id"
client.query(FetchCategoryItemsQuery.builder().input(categoryId.toString()).build())
        .responseFetcher(ApolloResponseFetchers.NETWORK_FIRST)
        .enqueue(object : ApolloCall.Callback<FetchCategoryItemsQuery.Data>() {
            override fun onFailure(exception: ApolloException) {
                Logger.debug(TAG, "${exception.message}")
            }

            override fun onResponse(response: Response<FetchCategoryItemsQuery.Data>) {
                    Logger.debug(TAG, "${response.data()?.items()?.size}")
                    Logger.debug(TAG, "error: ${response.errors()[0].message()}")
                }
            }
        })

您缺少 $ -- 您的变量定义为 $input 但您将其用作 input。没有 $,解析器假定 input 是枚举值而不是变量。