Search code examples
graphqlcommand-line-interfaceschemaapollo

Why does Apollo Client download:schema fail with "Error: Cannot find module 'graphql/validation/rules/UniqueTypeNames'"


I am trying to download a graphql schema with the command

apollo client:download-schema --endpoint=https://my-endpoint --header='x-hasura-admin-key: <my key>'

I get an error: Error: Cannot find module 'graphql/validation/rules/UniqueTypeNames'

I have the following dependencies and dev-dependencies in package.json

  "dependencies": {
    "@apollo/client": "^3.4.16",
    "@vue/apollo-composable": "^4.0.0-alpha.15",
    "core-js": "^3.6.5",
    "graphql": "^16.0.0",
    "graphql-tag": "^2.12.5",
    "vue": "^3.2.20",
    "vue-auth0-plugin": "^2.4.1",
    "vue-router": "^4.0.0-0"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^4.18.0",
    "@typescript-eslint/parser": "^4.18.0",
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-plugin-router": "~4.5.0",
    "@vue/cli-plugin-typescript": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "@vue/compiler-sfc": "^3.0.0",
    "@vue/eslint-config-typescript": "^7.0.0",
    "apollo": "^2.33.7",
    "eslint": "^6.7.2",
    "eslint-plugin-vue": "^7.0.0",
    "typescript": "~4.1.5"
  }

I have just deleted package-lock.json and rerun npm install but still get the same error.

Do I need to manually adjust a version for eithe apollo or graphql, and if so, to what? Or is there some other method to resolve this.

Thanks in advance.


Solution

  • The CLI is being deprecated for graph downloading. This code works:

    npx rover --output json graph introspect [url here] > schemas/[name here].json