android - 我可以在 Apollo Android 中使用 .gql 架构吗?(不生成类)
问题描述
我在尝试使用 Apollo Android 设置我的 GraphQL 查询时遇到问题。我有一个 .gql 架构而不是 json 架构。我设法用 Apollo iOS 客户端设置它,所以我只能假设架构很好,并且 Apollo Android 支持这个。(不过,我在他们的文档中找不到任何相关内容。)
目前项目构建没有错误,但我找不到任何生成的类。
除了下面的设置之外,我还尝试生成 Kotlin 类,将 useSemanticNaming 设置为 false 并且通常只是往墙上扔泥看看会粘住什么。
我目前的设置:
build.gradle(根)
buildscript {
ext.kotlin_version = '1.3.61'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath("com.apollographql.apollo:apollo-gradle-plugin:1.3.3")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
build.gradle(应用程序):
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.apollographql.apollo'
repositories {
jcenter()
}
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.test.apollotestapplication"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner2"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
apollo {
// NOTE: Putting this inside onCompilationUnit as suggested by the docs resulted in an error.
// NOTE 2: This is where the schema is.
schemaFile.set(file("/src/main/graphql/com.test.apollotestapplication/schema.gql"))
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation("com.apollographql.apollo:apollo-runtime:1.3.3")
compileOnly("org.jetbrains:annotations:13.0")
testCompileOnly("org.jetbrains:annotations:13.0")
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
我的架构:
type Job{
id: ID!
title: String!
location: String!
description: String
jobType: String!
}
type Query{
jobs: [Job!]!
}
schema{
query: Query
}
GraphQL 文件:
query Jobs {
jobs {
id
title
description
jobType
location
}
}
解决方案
推荐阅读
- apache-kafka - 如何在 DLQ 中自定义标头消息异常
- c# - 在 C# asp.net 中按相同顺序对列表中的相似项进行分组
- javascript - 是否有可能在 shadow dom 中使用 twitter bootstrap 的 css 类?
- caching - 我们什么时候执行缓存失效?
- sql-server - 如果我进行事务日志备份并截断日志文件,我会丢失数据吗?
- java - Java 程序无法执行它写入 /tmp 的文件,没有这样的文件或目录
- flutter - 在按钮上单击导航到选项卡屏幕
- java - 将空字段反序列化为 null 而不是采用默认值
- android - Xamarin App Android 上的输入调度超时错误
- reactjs - 当我调用 DrawerOpen 时,抽屉不会打开到 initialRouteName