Apollo-ios: Error with new code generation build step

Created on 7 Aug 2018  ·  13Comments  ·  Source: apollographql/apollo-ios

Intended outcome: I updated the apollo version and set the code generation step as mentioned in the iOS installation guide

APOLLO_FRAMEWORK_PATH="$(eval find $FRAMEWORK_SEARCH_PATHS -name "Apollo.framework" -maxdepth 1)"

if [ -z "$APOLLO_FRAMEWORK_PATH" ]; then
  echo "error: Couldn't find Apollo.framework in FRAMEWORK_SEARCH_PATHS; make sure to add the framework to your project."
  exit 1
fi

cd "${SRCROOT}/${TARGET_NAME}"
$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql')" --schema=schema.json API.swift

I was trying to rebuild the project.


Actual outcome:

Can't find Apollo CLI. Installing...
npm ERR! git clone --template=/Users/felipemarino/.npm/_git-remotes/_templates --mirror [email protected]:zap/canal-pro-ios.git /Users/felipemarino/.npm/_git-remotes/git-github-com-zap-canal-pro-ios-git-bee87431: Cloning into bare repository '/Users/felipemarino/.npm/_git-remotes/git-github-com-zap-canal-pro-ios-git-bee87431'...
npm ERR! git clone --template=/Users/felipemarino/.npm/_git-remotes/_templates --mirror [email protected]:zap/canal-pro-ios.git /Users/felipemarino/.npm/_git-remotes/git-github-com-zap-canal-pro-ios-git-bee87431: [email protected]: Permission denied (publickey).
npm ERR! git clone --template=/Users/felipemarino/.npm/_git-remotes/_templates --mirror [email protected]:zap/canal-pro-ios.git /Users/felipemarino/.npm/_git-remotes/git-github-com-zap-canal-pro-ios-git-bee87431: fatal: Could not read from remote repository.
npm ERR! git clone --template=/Users/felipemarino/.npm/_git-remotes/_templates --mirror [email protected]:zap/canal-pro-ios.git /Users/felipemarino/.npm/_git-remotes/git-github-com-zap-canal-pro-ios-git-bee87431: 
npm ERR! git clone --template=/Users/felipemarino/.npm/_git-remotes/_templates --mirror [email protected]:zap/canal-pro-ios.git /Users/felipemarino/.npm/_git-remotes/git-github-com-zap-canal-pro-ios-git-bee87431: Please make sure you have the correct access rights
npm ERR! git clone --template=/Users/felipemarino/.npm/_git-remotes/_templates --mirror [email protected]:zap/canal-pro-ios.git /Users/felipemarino/.npm/_git-remotes/git-github-com-zap-canal-pro-ios-git-bee87431: and the repository exists.
npm ERR! Darwin 17.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--prefix" "/Users/felipemarino/Documents/Projects/Grupo" "Zap/canal-pro-ios" "[email protected]"
npm ERR! node v6.11.5
npm ERR! npm  v3.10.10
npm ERR! code 128

npm ERR! Command failed: git clone --template=/Users/felipemarino/.npm/_git-remotes/_templates --mirror [email protected]:zap/canal-pro-ios.git /Users/felipemarino/.npm/_git-remotes/git-github-com-zap-canal-pro-ios-git-bee87431
npm ERR! Cloning into bare repository '/Users/felipemarino/.npm/_git-remotes/git-github-com-zap-canal-pro-ios-git-bee87431'...
npm ERR! [email protected]: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR! 
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR! 
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/felipemarino/Documents/Projects/Grupo Zap/canal-pro-ios/CanalPro/npm-debug.log
Command /bin/sh failed with exit code 1


How to reproduce the issue: Probably you should need an private repo with personal access token configured for your git account. I don't really know 🤷‍♂️.

Why does it need to clone the project repo to update/install apollo CLI?
Is there anyway to manually update it?
Sorry if I'm missing something here.

blocking

All 13 comments

Yeah, I would rather not have this command to get the Apollo CLI at all, would be better to hard fail with an error to make sure it is installed. I would vote to remove this altogether. Even when it does work, it dumps the node_packages into the current directory, even when you have the current version installed globally - it doesn't work in the best of times.

Same issue..

I've made some changes to the build script in Apollo iOS 0.9.3. Can you check if that fixes your issues?

Thank you @martijnwalraven ! I am going to check it.

Not sure if this is related, but I am setting up a new project following the official documentation and while find . -name '*.graphql' returns my single query file, and API.swift is generated, there is no code generated. I've specified the version with pod "Apollo", "0.9.3", no errors either. The transcript from the build script is\

 ›   Warning: apollo update available from 1.8.3 to 1.9.2
++ npx --no-install apollo codegen:generate --queries= --schema=../backend-prisma-sandbox/generated/backend-prisma-sandbox-graphql.json API.swift
 ›   Warning: apollo update available from 1.8.3 to 1.9.2
[?25l[22:59:12] Loading Apollo config [started]
[22:59:12] Loading Apollo config [completed]
[22:59:12] Resolving GraphQL document sets and dependencies [started]
[22:59:12] Scanning for GraphQL queries (8 found) [title changed]
[22:59:12] Scanning for GraphQL queries (8 found) [completed]
[22:59:12] Generating query files [started]
[22:59:12] Generating query files with 'swift' target [title changed]
[22:59:12] Generating query files with 'swift' target - wrote 1 files [title changed]
[22:59:12] Generating query files with 'swift' target - wrote 1 files [completed]
[?25h[?25h

@martijnwalraven Yeah, no more issues. Thank you!

before

Command PhaseScriptExecution failed with a nonzero exit code

Warning: apollo update available from 1.8.3 to 1.9.2

npm install -g apollo

after

warning: The version of Apollo.framework in your project requires Apollo CLI 1.8.x, but apollo/1.9.2 darwin-x64 node-v9.11.1 seems to be installed.

warning: The version of Apollo.framework in your project requires Apollo CLI 1.8.x, but apollo/1.9.2 darwin-x64 node-v9.11.1 seems to be installed.
note: Installing [email protected] in your project directory to avoid version conflicts...

[?25l[11:42:09] Loading Apollo config [started]
[11:42:09] Loading Apollo config [completed]
[11:42:09] Resolving GraphQL document sets and dependencies [started]
[11:42:09] Scanning for GraphQL queries (8 found) [title changed]
[11:42:09] Scanning for GraphQL queries (8 found) [completed]
[11:42:09] Generating query files [started]
[11:42:09] Generating query files with 'swift' target [title changed]
[11:42:09] Generating query files with 'swift' target [failed]
[11:42:09] → Cannot read property 'getMutationType' of undefined
[?25hTypeError: Cannot read property 'getMutationType' of undefined
at TypeInfo.enter (/usr/local/lib/node_modules/apollo/node_modules/graphql/utilities/TypeInfo.js:144:25)
at Object.enter (/usr/local/lib/node_modules/apollo/node_modules/graphql/language/visitor.js:363:16)
at Object.visit (/usr/local/lib/node_modules/apollo/node_modules/graphql/language/visitor.js:254:26)
at getValidationErrors (/usr/local/lib/node_modules/apollo/lib/validation.js:21:15)
at Object.validateQueryDocument (/usr/local/lib/node_modules/apollo/lib/validation.js:26:30)
at Object.generate [as default] (/usr/local/lib/node_modules/apollo/lib/generate.js:19:18)
at Task.task (/usr/local/lib/node_modules/apollo/lib/commands/codegen/generate.js:98:64)
at Promise.resolve.then.then.skipped (/usr/local/lib/node_modules/apollo/node_modules/listr/lib/task.js:167:30)
at
[?25hCommand PhaseScriptExecution failed with a nonzero exit code

bogon$ npx --version
9.7.1
bogon$ npx --no-install apollo --version
› Warning: apollo update available from 1.8.3 to 1.9.1
apollo/1.8.3 darwin-x64 node-v9.11.1

Have the same issue.
My project not hosted at github at all.

I too have this issue.

My issue was connected to upgrade to apollo-ios 0.9.3.
Solved it by installing apollo-cli v1,8 locally in source folder.

npm install --prefix <path_to_source_folder> [email protected]

My issue, which I have now fixed, wasn't connected to the version of the package. Instead, this answer helped me. Everything now works as expected.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wnagrodzki picture wnagrodzki  ·  4Comments

farice picture farice  ·  4Comments

hiteshborse12 picture hiteshborse12  ·  4Comments

Robuske picture Robuske  ·  3Comments

MrAlek picture MrAlek  ·  3Comments