apollo
apollo copied to clipboard
[Tutorial 5] Apollo does not support anonymous operations
I followed the whole tutorial from the start, till part 5 there was no issue whatsoever, but in part I got stuck at the Create an Apollo Client
section.
npm run codegen
throws an error without any hints on what to do and I haven't been able to find it on the internet either.
Could someone please point me in the right direction?
Create an Apollo Client The code blocks below use TypeScript by default. You can use the dropdown menu above a code block to switch to JavaScript.
If you're using JavaScript, use .js and .jsx file extensions wherever .ts and .tsx are mentioned.
To generate TypeScript types for your queries and mutations, open another terminal window and run npm run codegen. This will watch for changes to your code and generate the client-side typings.
$ npm run codegen
> [email protected] codegen /Users/matyas/dev/fullstack-tutorial/start/client
> apollo client:codegen --target typescript --watch
✔ Loading Apollo Project
✖ Generating query files with 'typescript' target
→ Apollo does not support anonymous operations
Press any key to stop.
$ apollo client:codegen --target typescript --verbose
✔ Loading Apollo Project
✖ Generating query files with 'typescript' target
→ Apollo does not support anonymous operations
GraphQLError: Apollo does not support anonymous operations
at GraphQLClientProject.get operations [as operations] (~/.npm-packages/lib/node_modules/apollo/node_modules/apollo-language-server/lib/project/client.js:266:31)
at write (~/.npm-packages/lib/node_modules/apollo/lib/commands/client/codegen.js:69:75)
at Task.task (~/.npm-packages/lib/node_modules/apollo/lib/commands/client/codegen.js:98:46)
It's not the entire problem, but I think the root cause is an anonymous gql query in one of the tests. In package.json
try changing the scripts entry for codegen to:
"codegen": "apollo client:codegen --target typescript --excludes '**/__tests__/*' --watch"