Closed fastman closed 4 years ago
Hi @fastman: you're totally right. I'm not totally sure what's messed up in the web of graphql dependencies, but the Apollo & graphql system is a bit of a mess there, and it needs sorting out.
In practice though as an end user you should be to ignore this. I'd like to fix the warning, but mockttp's dependencies should install & work fine regardless.
Of course do let me know if you are hitting concrete issues that might be caused by this (e.g. mockttp errors if other packages are installed), but I haven't seen anything like that myself, just the annoying warning.
@pimterry Eg. one of the issue is that apollo-cache-control@0.1.1
requires graphql
to be one of the version between 0.10.x - 0.13.x
but the version ^14.0.2
is installed as a dependency to mockttp
.
The same goes for other cases. Two solutions:
1) apollo-*
modules get updated
2) graphql
version in mockttp
is specified to match those peer dependencies requirements from apollo-*
Yes, I've tried to update some of these in the past. I believe it's a little more complicated than you'd expect though, as updates through some breaking changes are required, so it needs a little work & testing, and comes with some risk. It's definitely planned though, it's just not an urgent priority, as far as I'm aware.
Is this causing issues in your application?
Yeah, I'm perfectly aware of what a pain it would be to update those dependencies.
The problem is that it's impossible to use shrinkwrap/lock file to reliably reproduce the environment, And the workaround is not too good - you have to add "additional" version of graphql to match apollo-*
requirements, even if you don't use graphql
at all. You end up with something like this:
{
"name": "test_mockttp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1"
},
"devDependencies": {
"graphql": "^0.12.3",
"mockttp": "^0.16.1",
"react": "^16.8.6"
}
}
(ofc, react and express are just placeholders here)
The problem is that it's impossible to use shrinkwrap/lock file to reliably reproduce the environment
Is that true? Why?
As far as I'm aware, these warnings shouldn't affect lock files at all, I believe that peer dependencies only serve to provide these install warnings nowadays. As a quick test:
npm init -y
npm install mockttp
: prints this warning, but installs finenpm ci
: cleans & reinstalls happily from the lockfile, returns all goodnpm ci
will fail if the lockfile isn't sufficient to exactly reproduce the environment, so should be a reasonable way to test this.
Does that not match the behaviour you're seeing? Is there a way to directly reproduce your issue from the package.json above? I've tested it with & without the extra graphql dependency, and the only difference I can see is in the warnings on the initial npm install
. In both cases it looks to me like the lockfile is generated fine afterwards, and works as expected with npm install
and npm ci
.
@pimterry fair enough - works fine with npm 6.4.1
and 6.9.0
(bundled with node 8 and 10 respectively). Npm still complains about missing peer dependencies but at least shrinkwrap file is updated when adding mockttp
.
I've now fixed 1/3 of these (https://github.com/httptoolkit/mockttp/commit/4c074abf3086e3ec80154b4c10ec77bed58866d3), since they were quick and easy. The remaining 2/3s are harder, and all come from the dependency on apollo-server-express v1. Upgrading to v2 is non-trivial, and would increase the size of this package by nearly 30% just to get rid of these warnings, which is pretty annoying.
I'll investigate the rest at a later date. I'm likely to either dump Apollo and move to express-graphql, or maybe dump graphql entirely. When I initially set it up I had a different vision of querying the collected data, and I don't think it's necessary at all now, it's just extra weight and complexity.
I'm not going to do that in the short term, but medium term: watch this space.
As part of removing Apollo entirely, this is now 100% fixed on master :+1:
Hi, It looks like there is a problem with
graphql
dependency. Some modules requires (as a peer dependency) an older version ofgraphql
that is defined as a direct dependency ofmockttp
.Test case (note
UNMET PEER DEPENDENCY
error)