Hey! I have a hard time figuring out how to integrate type-graphql with apollo client:codegen.
root@23c4963e061e:/app# yarn apollo client:codegen --target=typescript --endpoint=http://localhost:80/graphql --includes="./src/**/*.ts"
yarn run v1.15.2
$ /app/node_modules/.bin/apollo client:codegen --target=typescript --endpoint=http://localhost:80/graphql '--includes=./src/**/*.ts'
✔ Loading Apollo Project
✖ Generating query files with 'typescript' target
→ Apollo does not support anonymous operations
(node:893) UnhandledPromiseRejectionWarning: GraphQLError: Apollo does not support anonymous operations
at GraphQLClientProject.get operations [as operations] (/app/node_modules/apollo-language-server/lib/project/client.js:206:31)
at write (/app/node_modules/apollo/lib/commands/client/codegen.js:58:75)
at GraphQLClientProject._onDiagnostics (/app/node_modules/apollo/lib/commands/client/codegen.js:84:29)
at GraphQLClientProject.validate (/app/node_modules/apollo-language-server/lib/project/client.js:132:18)
at GraphQLClientProject.validateIfNeeded (/app/node_modules/apollo-language-server/lib/project/base.js:135:14)
at Timeout._onTimeout (/app/node_modules/apollo-language-server/lib/project/base.js:127:22)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7)
(node:893) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:893) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
GraphQLError: Apollo does not support anonymous operations
at GraphQLClientProject.get operations [as operations] (/app/node_modules/apollo-language-server/lib/project/client.js:206:31)
at write (/app/node_modules/apollo/lib/commands/client/codegen.js:58:75)
at Task.task (/app/node_modules/apollo/lib/commands/client/codegen.js:86:46)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I've found this issue regarding Apollo does not support anonymous operations error.
Is it possible to automatically/manually name operations so they do not appear as anonymous?
It's not related to type-graphql. I guess you have queries like this:
{
items {
id
name
}
}
Instead of the named one:
query GetItems {
items {
id
name
}
}
You are right. Thanks! :)
It's not related to
type-graphql. I guess you have queries like this:{ items { id name } }Instead of the named one:
query GetItems { items { id name } }
@MichalLytek thanks!
Is it possible to just ignore anonymous queries and still proceed with all the remaining ones?
Most helpful comment
It's not related to
type-graphql. I guess you have queries like this:Instead of the named one: