【发布时间】:2022-02-03 17:22:10
【问题描述】:
我正在使用 GraphQL。架构包含:
scalar DateTime
type Something {
timestamp: DateTime
}
当我构建应用程序时,ApolloClient 插件会生成类:
public class DateTime {
public companion object {
public val type: CustomScalarType = CustomScalarType("DateTime", "kotlin.Any")
}
}
我在构建 ApolloClient 时必须使用这个吗?像这样?
val apolloClient = ApolloClient.builder()
.serverUrl("xxxx")
.okHttpClient(httpClient)
.addCustomTypeAdapter(DateTime.type, adapter)
.build()
我找到了here 已经可用的适配器列表,但我找不到如何导入它们,而且它们似乎都不合适。
我必须定义自己的自定义适配器吗?
编辑
要导入它们,只需导入 com.apollographql.apollo3:apollo-adapters。
【问题讨论】: