我无法将我的 Okhttp 客户端附加到 Apollo 客户端。我无法在
okhttpclient()
类中找到 ApolloClient.Builder
方法。它显示“无法解析‘Builder’中的方法‘okHttpClient’”错误。我正在使用 apollo 版本 3。
build.gradle(项目)
classpath "com.apollographql.apollo3:apollo-gradle-plugin:3.6.1"
build.gradle(应用程序)
// Graphql
def apollo3GraphqlVersion = '3.6.1'
implementation "com.apollographql.apollo3:apollo-runtime:$apollo3GraphqlVersion"
implementation "com.apollographql.apollo3:apollo-rx3-support:$apollo3GraphqlVersion"
客户端.class
apolloClient = new ApolloClient.Builder()
.serverUrl(baseUrl)
.okHttpClient() // error "Cannot resolve method 'okHttpClient' in 'Builder'"
.build();
有点晚了,但我找到了一种方法来做到这一点(版本3.8.2):
import com.apollographql.apollo3.ApolloClient
import com.apollographql.apollo3.network.http.DefaultHttpEngine;
apolloClient = new ApolloClient.Builder()
.serverUrl("")
.httpEngine(new DefaultHttpEngine(okHttpClient))