Apollo-ios: Installation fails via SPM - GraphQLError: Apollo does not support anonymous operations

Created on 21 Nov 2019  Â·  4Comments  Â·  Source: apollographql/apollo-ios

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
build-issue

Most helpful comment

So in short, you need to give your query a name

It could look like

query Viewer {
  viewer {
    login
  }
}

All 4 comments

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wnagrodzki picture wnagrodzki  Â·  4Comments

AnthonyMDev picture AnthonyMDev  Â·  4Comments

maxsz picture maxsz  Â·  4Comments

Robuske picture Robuske  Â·  3Comments

ermik picture ermik  Â·  4Comments