fix: graphql@17.0.0 compatibility - #1256
Conversation
mcollina
left a comment
There was a problem hiding this comment.
I would prefer if we could support both 16 and 17 at the same time, as a lot of people would not be able to upgrade graphql in time. This would require to fiddle with CI so that we run tests for both versions.
yes I agree, I just wanted to know what you thought first 😉 |
23bc028 to
4587340
Compare
|
I updated the files so as to have compatibility for graphql 16 and 17 and I also updated the CI file so it separates the tests for graphql 16 and 17, plus I added nodejs v26 🔥 |
mcollina
left a comment
There was a problem hiding this comment.
index.js has a lot of pure formatting changes (prettier?). Please revert them
|
keeping as semver-major as safety measure. |
I think it's my editor that formats everything to a maximum of 80 columns 😄 |
|
Please revert, this is very hard to review |
8e145bc to
7a38023
Compare
Ok, I think I've fixed it, see commit here: 7a38023. Sorry about the issues with the code indentation 🙏🏻 |
|
there are conflicts |
7a38023 to
344bfd8
Compare
I don't see any conflicts to resolve 😄, the CI is all green 🙌 ✅ |
|
I accidentally closed the PR 😅, sorry |
|
ok, the CI is all green 🙌 ✅ |
mercurius@16.10.0 (latest) peers graphql@^16.0.0, and both @mercuriusjs/federation and @mercuriusjs/gateway depend on mercurius@^16.0.0, so graphql 17 cannot be installed. The upstream compatibility fix (mercurius-js/mercurius#1256) is still unmerged; without it 73/376 mercurius tests fail under graphql 17. Dependabot PR #986 was closed as unmergeable. This ignore rule stops it being re-raised weekly while leaving graphql 16.x minor/patch updates flowing. Co-authored-by: Luis Villamarin <luis.villamarin@nearform.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Proposal:
mercuriuscompatibility withgraphql@17.0.0, while keeping support forgraphql@16at the same time so users who can't upgrade yet aren't forced to. Without the graphql@17 fixes, 73/376 tests failed after bumping the dependency (see here for preview: https://github.com/mercurius-js/mercurius/actions/runs/29320645825/job/87044889698#step:5:14).Changes:
index.js:buildExecutionContextwas removed fromgraphql/execution/executein graphql 17 → feature-detected against its drop-in successorvalidateExecutionArgs(same signature/behavior), falling back tobuildExecutionContexton graphql@16.lib/errors.js:GraphQLError's positional constructor was fully removed in graphql 17 (it's supported since graphql@16.3, so this works on both).toGraphQLError()used the old positional args, which silently droppedoriginalError— breaking status code mapping (validation/CSRF/persisted-query errors returned 200 instead of 400/405). Switched to the new options-object signature.index.js: graphql 17 tags ASTloc.sourcewith a non-cloneableSymbol, sostructuredClone()crashed on pre-parsed documents (e.g.graphql-tag). Replaced withrfdc(already in the fastify dep tree) for cloning — faster thanstructuredClone/JSON, and it naturally skips the Symbol-keyed brand without needing to striploc.package.json: widenedpeerDependencies.graphqlto^16.8.0 || ^17.0.0; addedrfdcas an explicit dependency.test/directives.test.js: the scalar-coercion error message wording differs between graphql-js 16 and 17, so the expected string is now resolved at runtime based on the installedgraphqlversion (via theversionexport —require('graphql/package.json')no longer works on @17, itsexportsmap blocks arbitrary subpaths).test/app-decorator.test.js: fixed a wrong assertion — mercurius wraps validationGraphQLErrors inMER_ERR_GQL_VALIDATION.errors[], the test was checking the wrong object (einstead ofe.errors[0])..github/workflows/ci.yml: added agraphql-version: [16, 17]matrix dimension, with a step that installs the matrix's graphql version after the regular install (--no-save), so both majors are covered in CI. Add node 26 to test matrix.Note: