Closed djordjeh closed 2 years ago
Hi! 👋
To understand what the problem could be, would it be possible for you to show the schema file for this service? It would also help a lot to see the actual stacktrace of the exception. Thanks!
Hi @BoD
Thank you for your response. How do you want me to send you schema file? The exception is classic NullPointException but I will prepare stacktrace of the exception.
You can attach the schema to this issue in a comment - or if that's preferable you can also send it privately to my email: benoit.lubek@apollographql.com.
Don't hesitate to also share the Query you're trying to execute and any other details that may help understand the issue.
Thank you!
Hi @djordjeh any news about this? Were you able to solve the issue or can we help with anything?
Hi @martinbonnin I've just send email to: benoit.lubek@apollographql.com with schema and query we are using. Thank you for your help and I apologize for late response.
Thanks! We'll look into that!
@martinbonnin I am facing same issue that in schema,we have a field as below
tags:[String!]
but During parsing Json from Response we get 2 different scenario 1-tags:null working fine during parsing from Apollo 2- tags:[ ] fails on StringAdapter() file during parsing
As we know ! denotes that it will not be null elements like
tags:[null,"element1",null,"element2"]
.So 2nd option should also works fine. Empty Array should be easliy parsed an emptyList().
@himanshufoodpanda thanks for sending the details! I added a test there: https://github.com/apollographql/apollo-kotlin/pull/4103. Unfortunately, I could not reproduce :(. So looks like there's more to it. Can you share your schema and Gradle configuration? (edit: also the full stacktrace would help a lot)
@himanshufoodpanda anything else we can do here ? Can you modify the test to make it fail by any chance ?
val mockServer = MockServer()
mockServer.enqueue("""
{
"data": {
"list": []
}
}
""".trimIndent())
val apolloClient = ApolloClient.Builder()
.serverUrl(mockServer.url())
.build()
val response = apolloClient.query(ListQuery()).execute()
Closing for now, don't hesitate to re-open if you can reproduce the issue.
Hi All, We have same problem. Summary My class items are nullable but I got cannot be cast to non-null type kotlin.String. Our schema item is like that "type": { "kind": "SCALAR", "name": "String", "ofType": null },
Version Version 3.4.0
Description For instance I have object which contains nullable strings. If I receive object like this:
[
{
"slug": "city-trips",
"title": "City Trips"
},
{
"slug": "no-test",
"title": "No test"
},
{
"slug": "europe",
"title": "Europe"
},
{
"slug": "february",
"title": "February"
},
{
"slug": null,
"title": null
}
]
Apollo drops the exception.
Thank you for any help
Hi @tekinarslan . In order to understand the issue, could you provide the full schema, the query, and the full payload you're receiving? If available, the full stacktrace of the exception would also help.
I can attach schema, query and response json. About exception, I also attached stacktrace as json file. I you need more thing, please let me know. error.zip
@tekinarslan Thank you. From the stacktrace it appears that the exception appears inside a class in your project named ContentfulCacheModule.kt
.
Hello, I found that I got error from cacheKeyGenerator in my ContentfulCacheModule. When cache key is null on response payload, my cache key get error. I think it is solved. I will let you know again after testing.
Summary If I receive the object with all nullable fields as null apollo drops NullPointException, cannot be cast to non-null type kotlin.String
Version Version 3.1.0
Description For instance I have object which contains three nullable strings. If I receive object like this:
"featuredTag": { "title": null, "slug": null, "color": null },
Apollo drops the exception. All fields inside are nullable. I was debugging line by line and noticed that exception occurs during the emit of flow. I know in perfect word I should receive object
featuredTag
as null and then everything works, but sometimes from some reason our API returns as above and our app is not able to parse the response.Thank you for any help, Cheers