4

我正在尝试在 Xcode 10 上构建示例 Apollo-IOS。我已遵循文档中描述的所有步骤:

Apolo-IOS 入门

有如下错误

++ npx --no-install apollo codegen:generate --queries=./GraphQL/Queries.graphql --schema=schema.json API.swift --passthroughCustomScalars
[?25l[22:26:11] Loading Apollo config [started]
[22:26:11] Loading Apollo config [completed]
[22:26:11] Resolving GraphQL document sets and dependencies [started]
[22:26:11] Scanning for GraphQL queries (1 found) [title changed]
[22:26:11] Scanning for GraphQL queries (1 found) [completed]
[22:26:11] Generating query files [started]
[22:26:11] Generating query files with 'swift' target [title changed]
[22:26:11] Generating query files with 'swift' target [failed]
[22:26:11] → Cannot read property 'getType' of undefined
[?25hTypeError: Cannot read property 'getType' of undefined
    at typeFromAST (/Volumes/Data/OneDrive/IOS/Source/GraphQL/JediArchives/JediArchives-Final/node_modules/graphql/utilities/typeFromAST.js:41:19)
    at TypeInfo.enter (/Volumes/Data/OneDrive/IOS/Source/GraphQL/JediArchives/JediArchives-Final/node_modules/graphql/utilities/TypeInfo.js:153:74)
    at Object.enter (/Volumes/Data/OneDrive/IOS/Source/GraphQL/JediArchives/JediArchives-Final/node_modules/graphql/language/visitor.js:363:16)
    at Object.visit (/Volumes/Data/OneDrive/IOS/Source/GraphQL/JediArchives/JediArchives-Final/node_modules/graphql/language/visitor.js:254:26)
    at getValidationErrors (/Volumes/Data/OneDrive/IOS/Source/GraphQL/JediArchives/JediArchives-Final/node_modules/apollo/lib/validation.js:21:15)
    at Object.validateQueryDocument (/Volumes/Data/OneDrive/IOS/Source/GraphQL/JediArchives/JediArchives-Final/node_modules/apollo/lib/validation.js:26:30)
    at Object.generate [as default] (/Volumes/Data/OneDrive/IOS/Source/GraphQL/JediArchives/JediArchives-Final/node_modules/apollo/lib/generate.js:19:18)
    at Task.task (/Volumes/Data/OneDrive/IOS/Source/GraphQL/JediArchives/JediArchives-Final/node_modules/apollo/lib/commands/codegen/generate.js:98:64)
    at Promise.resolve.then.then.skipped (/Volumes/Data/OneDrive/IOS/Source/GraphQL/JediArchives/JediArchives-Final/node_modules/listr/lib/task.js:167:30)
[?25hCommand PhaseScriptExecution failed with a nonzero exit code

看起来像我的Queries.graphql,并且schema.json在正确的位置,可以通过运行脚本找到。任何人都知道错误是什么以及如何解决(我已经更新到最新Apollo-Cli的 1.9.2)

4

2 回答 2

10

我有同样的问题。
仅在安装时检查运行脚本 并解决了问题。检查您是否勾选了该复选框仅在安装时运行脚本 在此处输入图像描述

于 2018-11-09T09:06:45.133 回答
1

对我来说 Xcode13。勾选构建基础下的“仅用于安装构建”复选框。工作正常

在此处输入图像描述

于 2021-12-21T07:21:06.550 回答