Skip to content

IllegalStateException when writing coordinates to JSON #5010

Closed as not planned
@Orbyt

Description

@Orbyt

Version

3.7.4

Summary

IllegalStateException occurs when executing query after migration to Apollo 3.

See log section for stacktrace.

The piece of input referenced ({"location":{"latitude":31.9496748,"longitude":-108.8067046}}) is definately valid JSON. The error gives no indication as to why that input cannot be written to JSON. The input code for the query has not really changed, with the exception of changes related to the use of Optionals as required by Apollo 3. The stack trace seems to reference generated *_InputAdapter classes in the project.

What might be the issue?

Steps to reproduce the behavior

N/A

Logs

java.lang.IllegalStateException: Cannot write {"location":{"latitude":31.9496748,"longitude":-108.8067046}} to Json
 	at com.apollographql.apollo3.api.json.-JsonWriters.writeAny(JsonWriters.kt:40)
 	at com.apollographql.apollo3.api.Adapters$AnyAdapter$1.toJson(Adapters.kt:203)
 	at com.apollographql.apollo3.api.Adapters$AnyAdapter$1.toJson(Adapters.kt:211)
 	at com.apollographql.apollo3.api.NullableAdapter.toJson(Adapters.kt:65)
 	at com.apollographql.apollo3.api.PresentAdapter.toJson(Adapters.kt:92)
 	at com.example.example.type.adapter.ProductRecommendationQuestionInput_InputAdapter.toJson(ProductRecommendationQuestionInput_InputAdapter.kt:37)
 	at com.example.example.type.adapter.ProductRecommendationQuestionInput_InputAdapter.toJson(ProductRecommendationQuestionInput_InputAdapter.kt:21)
 	at com.apollographql.apollo3.api.ObjectAdapter.toJson(Adapters.kt:313)
 	at com.apollographql.apollo3.api.NullableAdapter.toJson(Adapters.kt:65)
 	at com.apollographql.apollo3.api.ListAdapter.toJson(Adapters.kt:39)
 	at com.apollographql.apollo3.api.ListAdapter.toJson(Adapters.kt:25)
 	at com.apollographql.apollo3.api.NullableAdapter.toJson(Adapters.kt:65)
 	at com.example.example.adapter.ProductRecommendationQuery_VariablesAdapter.toJson(ProductRecommendationQuery_VariablesAdapter.kt:30)
 	at com.example.example.ProductRecommendationQuery.serializeVariables(ProductRecommendationQuery.kt:40)
 	at com.apollographql.apollo3.api.http.DefaultHttpRequestComposer$Companion.composePostParams(DefaultHttpRequestComposer.kt:116)
 	at com.apollographql.apollo3.api.http.DefaultHttpRequestComposer$Companion.access$composePostParams(DefaultHttpRequestComposer.kt:68)
 	at com.apollographql.apollo3.api.http.DefaultHttpRequestComposer$Companion.buildPostBody(DefaultHttpRequestComposer.kt:215)
 	at com.apollographql.apollo3.api.http.DefaultHttpRequestComposer.compose(DefaultHttpRequestComposer.kt:62)
 	at com.apollographql.apollo3.network.http.HttpNetworkTransport.execute(HttpNetworkTransport.kt:43)
 	at com.apollographql.apollo3.interceptor.NetworkInterceptor.intercept(NetworkInterceptor.kt:22)
 	at com.apollographql.apollo3.interceptor.DefaultInterceptorChain.proceed(ApolloInterceptor.kt:23)
 	at com.apollographql.apollo3.cache.http.HttpCache$httpCache$2.intercept(HttpCacheExtensions.kt:106)
 	at com.apollographql.apollo3.interceptor.DefaultInterceptorChain.proceed(ApolloInterceptor.kt:23)
 	at com.apollographql.apollo3.ApolloClient.executeAsFlow(ApolloClient.kt:178)
 	at com.apollographql.apollo3.ApolloCall.toFlow(ApolloCall.kt:97)
 	at com.apollographql.apollo3.ApolloCall.execute(ApolloCall.kt:106)
 	at com.example.example.data.remote.RemoteRepoImpl.getProductRecommendation(RemoteRepoImpl.kt:1333)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions