如何使用 gradle type:exec 下载 apollo 模式
How to download apollo schema using gradle type:exec
我想知道如何在 gradle 中执行 "apollo schema:download" 命令,这样我就不必在每次更新时都通过命令行生成架构。
我在整个 Whosebug 上搜索了类似的东西,但我似乎找不到任何东西。这就是我 运行 远:
//this will list all the files in my directory -- this works
task createSchema(type:Exec){
commandLine 'ls'
}
//but what i want to do is this -- this doesn't work
task createSchema(type:Exec){
commandLine 'apollo schema:download src/main/graphql/schema.json --endpoint="http://myendpoint.com" --header="myHeader: header"'
}
我的预期:
✔ 正在加载阿波罗计划
✔ 将架构保存到 src/main/graphql/schema.json
我得到了什么:
Cause: error=2, No such file or directory
apollo android 存储库的 github 问题解释了我的问题:https://github.com/apollographql/apollo-android/issues/683
我是怎么解决的:
import com.apollographql.apollo.gradle.ApolloSchemaIntrospectionTask
class ApolloIntrospect extends ApolloSchemaIntrospectionTask {}
task introspectSchema(type: ApolloIntrospect) {
url = "http://api.githunt.com/graphql"
output = project.projectDir.absolutePath + 'schema.json'
}
架构不得存在于 src/main/graphql 目录中,否则将引发错误。
我想知道如何在 gradle 中执行 "apollo schema:download" 命令,这样我就不必在每次更新时都通过命令行生成架构。
我在整个 Whosebug 上搜索了类似的东西,但我似乎找不到任何东西。这就是我 运行 远:
//this will list all the files in my directory -- this works
task createSchema(type:Exec){
commandLine 'ls'
}
//but what i want to do is this -- this doesn't work
task createSchema(type:Exec){
commandLine 'apollo schema:download src/main/graphql/schema.json --endpoint="http://myendpoint.com" --header="myHeader: header"'
}
我的预期:
✔ 正在加载阿波罗计划
✔ 将架构保存到 src/main/graphql/schema.json
我得到了什么:
Cause: error=2, No such file or directory
apollo android 存储库的 github 问题解释了我的问题:https://github.com/apollographql/apollo-android/issues/683
我是怎么解决的:
import com.apollographql.apollo.gradle.ApolloSchemaIntrospectionTask
class ApolloIntrospect extends ApolloSchemaIntrospectionTask {}
task introspectSchema(type: ApolloIntrospect) {
url = "http://api.githunt.com/graphql"
output = project.projectDir.absolutePath + 'schema.json'
}
架构不得存在于 src/main/graphql 目录中,否则将引发错误。