apollographql / apollo-tooling

✏️ Apollo CLI for client tooling (Mostly replaced by Rover)
https://apollographql.com
MIT License
3.04k stars 467 forks source link

apollo client:download-schema reports error #1934

Open cervmi opened 4 years ago

cervmi commented 4 years ago

My apollo.config.js is

module.exports = {
  client: {
    service: {
      name: 'Public API',
      url: 'DoesNotMatter',
      skipSSLValidation: true
    }
  }
}

and when I run apollo client:download-schema schema.json it returns:

CLIError: Error in "Loading queries for Public API": Error: ️️There are multiple definitions for the `apiFields` operation. Please rename or remove all operations with the d
uplicated name before continuing.
    at Object.error (C:\Data\Work\Zasilkovna\repo\ui\node_modules\@oclif\errors\lib\index.js:22:17)
    at SchemaDownload.error (C:\Data\Work\Zasilkovna\repo\ui\node_modules\apollo\node_modules\@oclif\command\lib\command.js:57:23)
    at OclifLoadingHandler.showError (C:\Data\Work\Zasilkovna\repo\ui\node_modules\apollo\lib\OclifLoadingHandler.js:28:22)
    at OclifLoadingHandler.handle (C:\Data\Work\Zasilkovna\repo\ui\node_modules\apollo\lib\OclifLoadingHandler.js:13:18) {
  oclif: { exit: 2 },
  code: undefined
}

Even when URL is not defined in config, it throws same error. But without this file it is not working. Does it looks to another configuration as well? Or where is problem?

MorganeLecurieux commented 3 years ago

Same problem here 😞

oclyke commented 3 years ago

related issue. i want to use the cli to download + maintain my schema file in src/schema/temp/graphql-schema.json, and i want to use codegen, so i need to have the following apollo.config.js:

module.exports = {
  client: {
    name: 'freestyle-client',
    service: {
      name: 'freestyle',
      localSchemaFile: './src/schema/temp/graphql-schema.json',
    },
  },
};

however as soon as i define the 'client' field in the config file i find an error with the following command:

npx apollo service:download --endpoint=http://localhost:4000/graphql src/schema/temp/graphql-schema.json

Error:

CLIError: Error in "Loading schema for Unnamed Project": Error: Type "Query" already exists in the schema. It cannot also be defined in this type definition.
...
kimdv commented 3 years ago

Any solutions to this problem? I have the same

cervmi commented 3 years ago

I solved it finally with proper arguments of apollo: without authorisation: apollo schema:download graphqlModel\\schemaPublic.json --endpoint=https://localhost:4443/api/public --skipSSLValidation

with authorisation: apollo schema:download graphqlModel\\schemaAdmin.json --endpoint=https://localhost:4443/api/admin --header="Authorization: Bearer bearerString" --skipSSLValidation