5

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

2 Answers 2

8

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

Sign up to request clarification or add additional context in comments.

Comments

0

operation name required. Something like below, required the name.

query {
  users {
    name
  }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.