1

我目前正在将旧项目的 Apollo 版本从 1.0.0-alpha 升级到 1.0.0 。

升级后我得到这个异常

com.apollographql.apollo.exception.ApolloParseException: Failed to parse http response
    at com.apollographql.apollo.internal.interceptor.ApolloParseInterceptor.parse(ApolloParseInterceptor.java:101)
    at com.apollographql.apollo.internal.interceptor.ApolloParseInterceptor$1.onResponse(ApolloParseInterceptor.java:53)
    at com.apollographql.apollo.internal.interceptor.ApolloServerInterceptor$1$1.onResponse(ApolloServerInterceptor.java:106)
    at okhttp3.RealCall$AsyncCall.execute(RealCall.java:203)
    at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:764)
 Caused by: java.io.EOFException: End of input
    at com.apollographql.apollo.internal.json.BufferedSourceJsonReader.nextNonWhitespace(BufferedSourceJsonReader.java:946)
    at com.apollographql.apollo.internal.json.BufferedSourceJsonReader.doPeek(BufferedSourceJsonReader.java:332)
    at com.apollographql.apollo.internal.json.BufferedSourceJsonReader.beginObject(BufferedSourceJsonReader.java:169)
    at com.apollographql.apollo.response.OperationResponseParser.parse(OperationResponseParser.java:82)
    at com.apollographql.apollo.internal.interceptor.ApolloParseInterceptor.parse(ApolloParseInterceptor.java:87)
    at com.apollographql.apollo.internal.interceptor.ApolloParseInterceptor$1.onResponse(ApolloParseInterceptor.java:53) 
    at com.apollographql.apollo.internal.interceptor.ApolloServerInterceptor$1$1.onResponse(ApolloServerInterceptor.java:106) 
    at okhttp3.RealCall$AsyncCall.execute(RealCall.java:203) 
    at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
    at java.lang.Thread.run(Thread.java:764) 

但是在我升级之前一切都很好。我从 alpha 升级到 1.0 stable 因为我升级了 Gradle 由于 Firebase Crashlytics migration 。

Apollo alpha 在新的 Gradle 中引发了构建错误。所以我升级到 1.0 并构建成功

但是打开应用程序后,我得到了这个异常

这里的奥秘是=>

okHTTP 日志拦截器打印响应 JSON,它也有效且正确。

但是 Apollo 无法解析它

为什么 apollo 在正确接收到 JSON 时无法解析它?

限制 一件可悲的事情是,由于使用了很多旧包,我无法升级到最新的 apollo 版本,因为旧包与新的 Gradle 6+ 和 apollo 最新版本不兼容需要新的 Gradle。

请帮我

信息:

  • Apollo 版本:1.0(1.0 alpha 之前)
  • Gradle 构建工具:3.6.4
  • 摇篮:5.6.4
  • 科特林:1.3.72

示例查询

#Get Profile Details
query GetProfile {
 userAccount {
 result {
 userId
 profileId
 firstName
 lastName
 displayName
 gender
 dateOfBirth
 iosDOB
 email
 userBanStatus
 phoneNumber
 preferredLanguage
 preferredLanguageName
 preferredCurrency
 location
 info
 createdAt
 picture
 country
 loginUserType
 isAddedList
 verification {
 id
 isEmailConfirmed
 isFacebookConnected
 isGoogleConnected
 isIdVerification
 isPhoneVerified
 }
 userData {
 type
 }
 verificationCode
 countryCode
 loginUserType
 isAddedList
 }
 status
 errorMessage
 }
 }

响应(来自 okhttp 记录器):

{
"data": {
"userAccount": {
"__typename": "WholeAccount",
"result": {
"__typename": "UserAccount",
"userId": "2bced470-49b7-11eb-a6aa-89804552bd8c",
"profileId": 28,
"firstName": "Ragesh",
"lastName": "Antony",
"displayName": "Ragesh Antony",
"gender": null,
"dateOfBirth": "6-1993-3",
"iosDOB": "6-3-1993",
"email": "ragesh@yopmail.com",
"userBanStatus": null,
"phoneNumber": null,
"preferredLanguage": null,
"preferredLanguageName": null,
"preferredCurrency": null,
"location": null,
"info": null,
"createdAt": "1609233662000",
"picture": "52cd186f3f176cd981a4085887cd019d.jpeg",
"country": null,
"loginUserType": "Guest",
"isAddedList": false,
"verification": {
"__typename": "UserVerifiedInfo",
"id": 28,
"isEmailConfirmed": true,
"isFacebookConnected": false,
"isGoogleConnected": false,
"isIdVerification": false,
"isPhoneVerified": false
},
"userData": {
"__typename": "UserType",
"type": "email"
},
"verificationCode": null,
"countryCode": null
},
"status": 200,
"errorMessage": null
}
}
}

====

阿波罗配置模块:

https://gist.github.com/RageshAntony/86686ebb9557698d8569acec6fc04b42

请帮我解决这个问题

4

0 回答 0