Open chenrui333 opened 3 years ago
Met same issue, but downgrading to 2.33.4 didn't help
I tried going all the way back to 2.20.0 just for kicks and it's broken with the same error:
"graphql-download": "npx apollo@2.20.0 schema:download --endpoint=https://..../graphql schema.json",
I thought using npx
with a pinned version would mean "this should never break", but I guess not?
I am having the same issue--downgrading does not help.
I tried going all the way back to 2.20.0 just for kicks and it's broken with the same error:
"graphql-download": "npx apollo@2.20.0 schema:download --endpoint=https://..../graphql schema.json",
I thought using
npx
with a pinned version would mean "this should never break", but I guess not?
I believe there's no package-lock.json
so it'll just get the latest ... and break.
I'm broken too as of 2+ hours ago on v2.22.0
Met same issue, but downgrading to 2.33.4 didn't help
@ralexandr @andrewlague @stephenh How did you downgrade?
Met same issue, but downgrading to 2.33.4 didn't help
@ralexandr @andrewlague @stephenh How did you downgrade?
npm i -D apollo@2.33.4
and then npm run apollo:push:dev
(i have "scripts": { "apollo:push:dev": "env-cmd --silent -f ./.env apollo service:push --variant=development", ... }
inside my package.json)
Pinning apollo
to 2.33.4
and apollo-language-server
to 1.26.3
worked for me
@Effanuel did you use npm i -g apollo-language-server@1.26.3
to pin it or your package.json
file? I still can't seem to get it to work.
I have the same error as the screenshot on environment node v16.6.2. When I downgrade node to v14.17.5 (npm v6.14.14) and re-install it's worked for me.
@Effanuel did you use
npm i -g apollo-language-server@1.26.3
to pin it or yourpackage.json
file? I still can't seem to get it to work.
Just add apollo with a veraion to devdeps
Is there any solution except downgrading nodejs and/or npm's and/or apollo's versions ?
@Effanuel did you use
npm i -g apollo-language-server@1.26.3
to pin it or yourpackage.json
file? I still can't seem to get it to work.
package.json:
"apollo": "2.33.4",
"apollo-language-server": "1.26.3",
On Node v16.8.0
, when I try to pin by adding versions to package.json
(I'm in a monorepo, this has been added to the root package.json
), I get the following error:
CLIError: Error in "Loading schema for core": Error: Cannot use GraphQLSchema "[object GraphQLSchema]" from another module or realm.
Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.
https://yarnpkg.com/en/docs/selective-version-resolutions
Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.
This may be specific to my case, but it results in this fix not working for me (everything worked as of a week ago, and nothing in my code has changed). Presumably this is an internal dependency issue within Apollo?
Hi, we were stuck on this and was blocking us.
This is what worked for us:
Switching to yarn worked for us somehow, hope this can help.
This issue is caused by apollo-language-server
requiring @apollo/federation@0.27.0
but @apollo/federation@0.27.0
no longer working with graphql@14
(see https://github.com/apollographql/federation/issues/904). @apollo/federation
corrected this issue in 0.27.1 by requiring graphql@15.4
or higher as peer dependency, dropping the support for graphql@14
.
There are 2 options to fix this issue here:
@apollo/federation
inside apollo-language-server
to a version that still works with graphql@14
graphql@15.4
(currently they are not, see e.g. https://github.com/apollographql/apollo-tooling/issues/2232) and drop support for any graphql
version lower than 15.4.Any updates on this?
For us, downgrading to "2.33.4"
(no need for "apollo-language-server
) was enough to restore functionality. Still unclear though
I'm having the same issue I tried to use npx to use the latest then tried with 2.33.4
and also 2.20.0
and neither of them worked.
npx apollo@2.20.0 schema:download --endpoint=https://graphql-pokeapi.graphcdn.app/graphql schema.json
Error: Cannot find module 'graphql/validation/rules/KnownArgumentNamesRule'
Require stack:
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@apollo/federation/dist/composition/validate/preNormalization/tagDirective.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@apollo/federation/dist/composition/validate/preNormalization/index.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@apollo/federation/dist/composition/validate/index.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@apollo/federation/dist/composition/composeAndValidate.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@apollo/federation/dist/composition/index.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@apollo/federation/dist/index.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/apollo-language-server/lib/providers/schema/file.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/apollo-language-server/lib/providers/schema/index.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/apollo-language-server/lib/project/base.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/apollo-language-server/lib/index.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/apollo/lib/Command.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/apollo/lib/commands/service/download.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@oclif/config/lib/plugin.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@oclif/config/lib/config.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@oclif/config/lib/index.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@oclif/command/lib/command.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@oclif/command/lib/index.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/apollo/bin/run
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:941:15)
at Function.Module._load (node:internal/modules/cjs/loader:774:27)
at Module.require (node:internal/modules/cjs/loader:1013:19)
at require (node:internal/modules/cjs/helpers:93:18)
at Object.<anonymous> (C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@apollo/federation/dist/composition/validate/preNormalization/tagDirective.js:6:34)
at Module._compile (node:internal/modules/cjs/loader:1109:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
at Module.load (node:internal/modules/cjs/loader:989:32)
at Function.Module._load (node:internal/modules/cjs/loader:829:14)
at Module.require (node:internal/modules/cjs/loader:1013:19)
Okay made it work guys, using the latest version of the package but using node 14.16.0
:
npx apollo schema:download --endpoint=https://graphql-pokeapi.graphcdn.app/graphql schema.json
The moment I changed node version with nvm everything worked 🙏
I've tried all of the above and this is still not working for me. Node is version 14.17.4
, installed apollo globally at version 2.33.4
, pinned Apollo in the app at the same version and "apollo-language-server": "1.26.3",
Having this issue all of a sudden as well. Tried pinning apollo
and apollo-language-server
as specified above but no luck.
Got tired of waiting and the proposed fixes didn't work for me, so I switched to graphql-code-generator.
Differences:
Edit: I think I've got a good configuration now: I've moved the gql
tag stuff into something.gql
files, pointed the apollo.config.js
file to only include those files (so I don't lose VSCode Apollo app autocompletion etc), and running graphql-code-generator on those to generate the TypeScript hooks
I've added the following postinstall script to the scripts section of my package.json
and it work for me and my co-worker:
"postinstall": "rm -r node_modules/apollo-language-server/node_modules/graphql"
I had the same issue with our CI workflow and the downgrading didn't help.
But installing graphql helps npm install -g graphql
I'm running into this issue as well, posting for notifications and updates 👍 I was following this tutorial on a fresh project. https://www.apollographql.com/blog/tooling/apollo-codegen/typescript-graphql-code-generator-generate-graphql-types/
Locking the versions and installing graphql
did not help.
How is this not getting more traction?
We wanted to be able to run apollo client:codegen
as an npm script to update our TypeScript types. This turned out to be kind of awkward because we’d followed vue-apollo’s instructions and had already indirectly installed Apollo’s sub-dependencies via apollo-boost
. We did manage to get the CLI to work for a few months with the following combination of explicit dependencies (dev and otherwise):
apollo-boost@0.4.9
(for base vue-apollo
installation)graphql@15.5.0
(for base vue-apollo
installation)vue-apollo@3.0.7
apollo-utilities@1.3.4
(added later to configure the in-memory cache)apollo@2.33.6
(for the codegen
CLI)Then, about a week ago, we had to reinitialize our package-lock.json
(for reasons I’ll not get into here) and came across the same error as in this ticket (Cannot find module 'graphql/validation/rules/KnownArgumentNamesRule'
). @WIStudent does an excellent root cause analysis in their comment above. No combination of downgrades resolved the error.
Our workaround was to uninstall our apollo
dependency and change our npm scripts to use npx apollo client:codegen
instead. Of course, npx
has to install all the dependencies it needs at runtime, but they do at least resolve to a combination of dependencies that work.
I solved putting "graphql" in peerDependencies in package.json
@OuthBack do you mind giving more contexto to how you solved this issue? thanks :D
@stephichau I was in my project using node v16.13.0, NPM v8.1.0, graphql v16.0.1 and apollo v2.33.8. It was giving me this same error, so I put graphql in peerDependencies, removed node_modules and installed again. But in another project this approch didn't work. The node, npm, graphql and apollo versions are old and cannot update them. So I installed graphql and apollo globally, because I just needed the schema file.
Guys the solution for this is that you need to check the version of your graphql that is compatible with your apollo. For example: i had the graphql version 14.5.8 and my apollo version was 2.33.9. These are not compatible. I had to check in my node_modules the folder for apollo, check the package.json ((you should see something like this "graphql": "14.0.2 - 14.2.0 || ^14.3.1 || ^15.0.0")) and wich versions are compatible with the version that i current had. In this case i just update it to graphql 15.8.0. And it works
It feels like some (peer-?)dependency is misconfigured in Apollo though, because I cannot run npx apollo@2.33.6
anymore, and that installs that version in it's own environment so it doesn't conflict with any other dependencies. That also means that I cannot select the version of graphql
that gets installed though...
This issue is still a problem. It gave me 12-hours of pain. Nothing in this thread solved it for me although the information and context were very useful.
These pinned devDependencies
worked for me:
"apollo": "2.33.4",
"apollo-codegen-core": "0.40.3",
"apollo-language-server": "1.26.3",
@LukeAvsec-DarwinHomes man you are a life saver
Adding GraphQL worked for me
Another workaround if you only use the apollo service:*
commands is switching to Apollo Rover because these commands are deprecated in Apollo CLI.
This issue is still a problem. It gave me 12-hours of pain. Nothing in this thread solved it for me although the information and context were very useful.
These pinned
devDependencies
worked for me:"apollo": "2.33.4", "apollo-codegen-core": "0.40.3", "apollo-language-server": "1.26.3",
@LukeAvsec-DarwinHomes Thank you so much. Was trying to fix versions for a long time, couldn't find the right one till now!
If you're using Node 16, see @LukeAvsec-DarwinHomes's solution above.
@traviscollins for us @LukeAvsec-DarwinHomes solution is not working with node v16.13.1
but v12.18.4
.
What worked for me on a mac:
brew install node@16
yarn global add apollo
it worked!! it worked!! thanks @LukeAvsec-DarwinHomes
What a Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega BUG
WOW. Please someone from Apollo fix this! (Almost 1 year later).
installing apollo globally and then running the codegen worked for me
npm i -g apollo
apollo -v
apollo/2.33.10 win32-x64 node-v16.14.2
apollo service:download --endpoint=ENDPOINT graphql-schema.json
running the apollo service through a package.json script stil doesn't work
@traviscollins for us @LukeAvsec-DarwinHomes solution is not working with node
v16.13.1
butv12.18.4
.
fwiw @LukeAvsec-DarwinHomes 's solution is working for me w/ node v16.14.1
(using graphql ^14.7.0
)
I think issue is on mac devices
I've tried on a windows PC instead of mac with following versions
apollo/2.34.0 win32-x64 node-v10.15.3
That worked for me
installing apollo globally and then running the codegen worked for me
npm i -g apollo
apollo -v apollo/2.33.10 win32-x64 node-v16.14.2
apollo service:download --endpoint=ENDPOINT graphql-schema.json
running the apollo service through a package.json script stil doesn't work
This is working well, thanks!
Which will happen first: this gets fixed, or George R.R. Martin releases his next GoT book?
anybody tried this on an arm64/M1? solutions from above didn't work for me.
anybody tried this on an arm64/M1? solutions from above didn't work for me.
Consider using the Rover CLI instead of a deprecated tool.
Consider using the Rover CLI instead of a deprecated tool.
Rover CLI doesn't support codegen yet
When I was trying to upgrade the formula to use the latest 2.33.6 release, it looks like the apollo command does not work anymore.
relates to https://github.com/Homebrew/homebrew-core/pull/83152