Kotlin 我怎样才能在科特林与阿波罗/graphql合作?
我确信graphql是一件好事,我喜欢用graphql创建后端系统,并用GraphiQL进行设置,这真的很好,但后来我发现每个人都在谈论apollo(代码生成)这件事,它应该是前端开发人员连接api的“方式”,现在我正试图理解这一点,我正试图创建一个android应用程序,它将连接到graphql服务器 我真的怀疑阿波罗,因为:Kotlin 我怎样才能在科特林与阿波罗/graphql合作?,kotlin,graphql,apollo,kotlin-coroutines,Kotlin,Graphql,Apollo,Kotlin Coroutines,我确信graphql是一件好事,我喜欢用graphql创建后端系统,并用GraphiQL进行设置,这真的很好,但后来我发现每个人都在谈论apollo(代码生成)这件事,它应该是前端开发人员连接api的“方式”,现在我正试图理解这一点,我正试图创建一个android应用程序,它将连接到graphql服务器 我真的怀疑阿波罗,因为: 它只是生成了一堆我不懂的代码 看起来一个简单的请求过于复杂了 文档不是完全最新的(我收到了弃用警告) 我能找到的唯一教程都在它们自己的页面上 但是我一直在尝试,因为
- 它只是生成了一堆我不懂的代码
- 看起来一个简单的请求过于复杂了
- 文档不是完全最新的(我收到了弃用警告)
- 我能找到的唯一教程都在它们自己的页面上
范围
,因为他们是以抽象的方式编写的,我以前只使用过全局范围
,我不知道我应该特别关注这种场景
我在运行代码时遇到此错误:
E/AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-1
Process: sh.mama.galgeleg, PID: 29866
java.lang.IllegalStateException: Module with the Main dispatcher had failed to initialize
at kotlinx.coroutines.internal.MissingMainCoroutineDispatcher.missing(MainDispatchers.kt:113)
at kotlinx.coroutines.internal.MissingMainCoroutineDispatcher.isDispatchNeeded(MainDispatchers.kt:91)
at kotlinx.coroutines.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:285)
at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:26)
at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:109)
at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:158)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56)
at kotlinx.coroutines.BuildersKt.launch(Unknown Source:1)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:49)
at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source:1)
at sh.mama.hangman.PickContextActivity$getCSV$1.invokeSuspend(PickContextActivity.kt:79)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
Caused by: java.lang.AbstractMethodError: abstract method "java.lang.String kotlinx.coroutines.internal.MainDispatcherFactory.hintOnError()"
at kotlinx.coroutines.internal.MainDispatchersKt.tryCreateDispatcher(MainDispatchers.kt:59)
at kotlinx.coroutines.internal.MainDispatcherLoader.loadMainDispatcher(MainDispatchers.kt:38)
at kotlinx.coroutines.internal.MainDispatcherLoader.<clinit>(MainDispatchers.kt:22)
at kotlinx.coroutines.Dispatchers.getMain(Dispatchers.kt:58)
at sh.mama.hangman.PickContextActivity$getCSV$1.invokeSuspend(PickContextActivity.kt:79)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
这是我的GetWords.graphql文件
query GetWords($title:String!) {
getCategory(title: $title) {
word
}
}
另外,我正在接收的word
类型是一个包含多个实体的对象,但我无法访问它们,也没有说我必须在任何地方定义它们。它只要求我运行连接到端点并生成schema.json的脚本