I am trying to install Apollo via the Swift Package Manager and I get the following error.
I have the schema.json file and a simple query.graphql file in the project's directory, one level deep (along with the AppDelegate).
I tried following the installation steps but using Cocoapods and it seems to be working. Any idea why installing using SPM fails?
query {
viewer {
login
}
}
Checking if CLI needs to be downloaded...
Zip file already downloaded!
Correct version of the CLI tarball is downloaded locally, checking if it's already been extracted...
Current verson of CLI is already extracted!
› Warning: apollo update available from 2.21.0 to 2.21.1.
Apollo CLI Information: apollo/2.21.0 darwin-x64 node-v10.16.3
+ /Users/tarek/Library/Developer/Xcode/DerivedData/GraphQL-dbubwnimayrulveizxwkrrascdby/SourcePackages/checkouts/apollo-ios/scripts/apollo/bin/run codegen:generate --target=swift '--includes=./**/*.graphql' --localSchemaFile=schema.json API.swift
› Warning: apollo update available from 2.21.0 to 2.21.1.
Loading Apollo Project [started]
Loading Apollo Project [completed]
Generating query files [started]
Generating query files with 'swift' target [title changed]
Generating query files with 'swift' target [failed]
→ Apollo does not support anonymous operations
GraphQLError: Apollo does not support anonymous operations
at GraphQLClientProject.get operations [as operations] (~/Library/Developer/Xcode/DerivedData/GraphQL-dbubwnimayrulveizxwkrrascdby/SourcePackages/checkouts/apollo-ios/scripts/apollo/node_modules/apollo-language-server/lib/project/client.js:266:31)
at write (~/Library/Developer/Xcode/DerivedData/GraphQL-dbubwnimayrulveizxwkrrascdby/SourcePackages/checkouts/apollo-ios/scripts/apollo/lib/commands/client/codegen.js:60:75)
at Task.task (~/Library/Developer/Xcode/DerivedData/GraphQL-dbubwnimayrulveizxwkrrascdby/SourcePackages/checkouts/apollo-ios/scripts/apollo/lib/commands/client/codegen.js:88:46)
Command PhaseScriptExecution failed with a nonzero exit code
Please look at #915 😅
So in short, you need to give your query a name
It could look like
query Viewer {
viewer {
login
}
}
Oh thanks a lot!
I guess I can close the issue now
Gonna close this out since @TarekSalama said it was cool - thanks for your help @kimdv!
Most helpful comment
So in short, you need to give your query a name
It could look like