【发布时间】:2019-01-20 05:10:14
【问题描述】:
我想将 apollo 框架添加到我的 iOS 项目中。我正在关注documentation,但无法构建它。
- 我通过 cocoapods 安装 apollo
- 我向我的目标添加了一个代码生成构建步骤(将它放在编译源之上...)
- 我通过 apollo 模式下载模式:下载 --endpoint=http://localhost:4000/graphqlschema.json。我将 schema.json 文件添加到项目的根目录中。
-
我构建它并收到以下错误:
- apollo@1.2.0
在 20.385 秒内增加了 416 个包
++ exec /Users/PATH/node_modules/.bin/apollo codegen:generate --queries= --schema=schema.json API.swift
› 警告:从 1.2.0 到 1.7.0 的 apollo 更新可用
› 错误:标志 --queries 需要一个值
命令 /bin/sh 失败,退出代码为 2
- apollo@1.2.0
在 20.385 秒内增加了 416 个包
++ exec /Users/PATH/node_modules/.bin/apollo codegen:generate --queries= --schema=schema.json API.swift
› 警告:从 1.2.0 到 1.7.0 的 apollo 更新可用
› 错误:标志 --queries 需要一个值
我的 schema.grapqhl 文件类似于:
type Query {
""" User """
users: [User!]!
user(username: String!): User
""" Question """
questions: [Question!]!
question(id: Int!): Question
}
type Mutation {
""" User """
createUser(username: String!): User
updateUser(username: String!, newUsername: String!): [Int!]!
deleteUser(username: String!): Int!
""" Question """
createQuestion(text: String!, category: Int!, active: Boolean!):
Question
updateQuestion(id: Int!, text: String!, category: Int!, active: Boolean!): [Int!]!
deleteQuestion(id: Int!): Int!
}
type Subscription {
answerAdded: Answer
}
type Question {
id: Int!
text: String!
categoryId: QuestionCategory!
active: Boolean!
createdAt: String!
updatedAt: String!
}
......
查询参数似乎没有输入: apollo codegen:generate --queries= --schema=schema.json API.swift
如果我自己通过终端尝试一下
apollo codegen:generate --queries=schema.graphql --schema=schema.json API.swift
我收到以下错误:
Warning: apollo update available from 1.2.0 to 1.7.0
.../schema.graphql: The Query definition is not executable.
.../schema.graphql: The Mutation definition is not executable.
.../schema.graphql: The Subscription definition is not executable.
.../schema.graphql: The Question definition is not executable.
... some more ...
:heavy_check_mark: Scanning for GraphQL queries (1 found)
:heavy_check_mark: Loading GraphQL schema
:heavy_check_mark: Parsing GraphQL schema
:heavy_multiplication_x: Generating query files with 'swift' target
→ Validation of GraphQL query document failed
ToolError: Validation of GraphQL query document failed
at Object.validateQueryDocument
....
能否请您帮忙找出我无法构建该项目的原因?是不是因为我的 schema.graphl 文件不对?
【问题讨论】: