Crash because of Unsupported Type
IHNEL opened this issue · comments
My code worked fine on version 0.5.0, but always crash because of Unsupported Type after upgrade to 0.5.1 or 0.6.0
Here is the crash log:
Process: cn.fashicon.fashicon.development, PID: 17760
java.lang.RuntimeException: Unable to start activity ComponentInfo{cn.fashicon.fashicon.development/cn.fashicon.fashicon.home.TabActivity}: java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.RuntimeException:
at me.lazmaid.kraph.lang.GraphQLNode.convertToDataEntry(GraphQLNode.kt:35)
at me.lazmaid.kraph.lang.GraphQLNode.access$convertToDataEntry(GraphQLNode.kt:3)
at me.lazmaid.kraph.lang.GraphQLNode$print$1.invoke(GraphQLNode.kt:13)
at me.lazmaid.kraph.lang.GraphQLNode$print$1.invoke(GraphQLNode.kt:3)
at kotlin.text.StringsKt__StringBuilderKt.appendElement(StringBuilder.kt:59)
at kotlin.collections.CollectionsKt___CollectionsKt.joinTo(_Collections.kt:2023)
at kotlin.collections.CollectionsKt___CollectionsKt.joinToString(_Collections.kt:2038)
at kotlin.collections.CollectionsKt___CollectionsKt.joinToString$default(_Collections.kt:2037)
at me.lazmaid.kraph.lang.GraphQLNode.print(GraphQLNode.kt:12)
at me.lazmaid.kraph.lang.Argument.print(Argument.kt:12)
at me.lazmaid.kraph.lang.Field.print(Field.kt:17)
at me.lazmaid.kraph.lang.SelectionSet$print$fieldStr$1.invoke(SelectionSet.kt:15)
at me.lazmaid.kraph.lang.SelectionSet$print$fieldStr$1.invoke(SelectionSet.kt:7)
at kotlin.text.StringsKt__StringBuilderKt.appendElement(StringBuilder.kt:59)
at kotlin.collections.CollectionsKt___CollectionsKt.joinTo(_Collections.kt:2023)
at kotlin.collections.CollectionsKt___CollectionsKt.joinToString(_Collections.kt:2038)
at kotlin.collections.CollectionsKt___CollectionsKt.joinToString$default(_Collections.kt:2037)
at me.lazmaid.kraph.lang.SelectionSet.print(SelectionSet.kt:15)
at me.lazmaid.kraph.lang.Field.print(Field.kt:16)
at me.lazmaid.kraph.lang.SelectionSet$print$fieldStr$1.invoke(SelectionSet.kt:15)
at me.lazmaid.kraph.lang.SelectionSet$print$fieldStr$1.invoke(SelectionSet.kt:7)
at kotlin.text.StringsKt__StringBuilderKt.appendElement(StringBuilder.kt:59)
at kotlin.collections.CollectionsKt___CollectionsKt.joinTo(_Collections.kt:2023)
at kotlin.collections.CollectionsKt___CollectionsKt.joinToString(_Collections.kt:2038)
at kotlin.collections.CollectionsKt___CollectionsKt.joinToString$default(_Collections.kt:2037)
at me.lazmaid.kraph.lang.SelectionSet.print(SelectionSet.kt:15)
at me.lazmaid.kraph.lang.Operation.print(Operation.kt:19)
at me.lazmaid.kraph.lang.Document.print(Document.kt:15)
at me.lazmaid.kraph.Kraph.toRequestString(Kraph.kt:42)
at cn.fashicon.fashicon.data.DataProvider.getProfileInfo(DataProvider.java:237)
at cn.fashicon.fashicon.profile.domain.usecase.GetProfileInfo.buildUseCase(GetProfileInfo.java:25)
at cn.fashicon.fashicon.profile.domain.usecase.GetProfileInfo.buildUseCase(GetProfileInfo.java:16)
at cn.fashicon.fashicon.NetworkUseCase.execute(NetworkUseCase.java:51)
at cn.fashicon.fashicon.NetworkUseCase.execute(NetworkUseCase.java:47)
at cn.fashicon.fashicon.home.TabPresenter.getMe(TabPresenter.java:190)
at cn.fashicon.fashicon.home.TabActivity.onCreate(TabActivity.java:185)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at cn.jiguang.a.a.d.a.a.d.callActivityOnCreate(Unknown Source:24)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) ```
And this is the query:
``` fun getProfileInfo(userId: String, myUserId: String, first: Int, after: String): Kraph {
return Kraph {
query {
fieldObject("user", args = mapOf("userId" to userId)) {
field("userId")
field("profileMediaUrl")
field("followingCount")
field("followerCount")
field("lookCount")
field("username")
field("userSig")
field("userType")
field("isLoggedInTencent")
field("followed: isFollowedBy", args = mapOf("followerId" to myUserId))
fieldObject("badgeInfo") {
fieldObject("lookLevel") {
field("levelKey")
field("nextLevelKey")
field("from")
field("to")
}
fieldObject("adviceLevel") {
field("levelKey")
field("nextLevelKey")
field("from")
field("to")
}
}
fieldObject("lookScoreInfo: scoreInfo", args = mapOf("by" to LeaderBoardBy.LOOKS_RATINGS, "period" to LeaderBoardPeriod.ALL_TIME)) {
field("score")
}
fieldObject("adviceScoreInfo: scoreInfo", args = mapOf("by" to LeaderBoardBy.ADVICE_RATINGS, "period" to LeaderBoardPeriod.ALL_TIME)) {
field("score")
}
}
fieldObject("looksPaginated", args = mapOf("userId" to userId, "first" to first, "after" to after)) {
fieldObject("edges") {
fieldObject("node") {
field("lookId")
field("userId")
field("title")
field("totalRating")
fieldObject("rating", args = mapOf("raterId" to myUserId)) {
field("raterId")
field("lookId")
field("stars")
}
field("adviceCount")
fieldObject("lookMedias") {
field("title")
field("url")
fieldObject("tags"){
fieldObject("brand"){
field("brandId")
field("name")
}
fieldObject("category"){
field("categoryId")
field("name")
}
fieldObject("location"){
field("x")
field("y")
}
}
}
}
}
fieldObject("pageInfo") {
field("endCursor")
field("hasNextPage")
}
}
}
}
}
WHich was wrong in my situation?
Hi, @IHNEL It seems that you are using enum in the arguments and Kraph did not support it. If you have the function to convert enum to String
or whatever data you want to put in query. It should work. If not, please let me know.
yes exactly it's Enum type, It's unable to remove these enum types from my project so I'm looking for a workaround to make it works again.
Btw, I didn't have any problem with version 0.5.0 and older, I guess you add some validator around this.
@VerachadW
I did some refactoring to support data for 'Map' type before. Maybe that can be a problem. I will take a look how to support enum more properly in the future.
Hey @VerachadW
Do you have any plan for the enum type?
Thanks
@IHNEL I already checked and don't see a good way to handle enum properly since it can be any value based on your requirement. The only way would be to have an interface and allow you to implement what is the value that you wanted. IMHO, This is a bit overkill for kraph. I suggest you should do the mapper from your enum to the value that your server wanted instead.
@VerachadW Thanks for your time, but how come you did support enum on version 0.5 and prior?
btw, I will folk this repo and give it a try.
Since we just added the simple support for Enum in #25. I will close this issue.