Reputation: 97
I have backend on Express with Apollo Graph.
In my client React app im do next:
apollo codegen:generate --excludes=node_modules/* --includes=**/*.tsx --target typescript --tagName gql --outputFlat generate
I wait for folder generated, but this command gives me next error:
Error: There are multiple definitions for the herewas operation.
All operations in a project must have unique names.
If generating types, only the types for the first definition
found will be generated.at GraphQLClientProject.checkForDuplicateOperations
(....\node_modules\apollo\node_modules\apollo-language-server\lib\project\base.js:129:31)
.........
.........
Generating query files with 'typescript' target
> Apollo does not support anonymous operations
Also i have apollo.config.js:
module.exports = {
client: {
service: {
url: "http://localhost:4000/graphql"
}
}
}
I do not understand where to dig, the code took from Google search
Upvotes: 5
Views: 4167
Reputation: 95
Apollo does not support anonymous operations
You should give your query/mutation operation a name :
This will work:
query SOME_NAME {
users {
age
}
}
This will NOT work (note that query name is missing):
query {
users {
age
}
}
Also you can check this thread: https://github.com/apollographql/apollo-tooling/issues/184
Upvotes: 8
Reputation: 31
operation name required. Something like below, required the name.
query {
users {
name
}
}
Upvotes: 0