dotansimha / graphql-code-generator

A tool for generating code based on a GraphQL schema and GraphQL operations (query/mutation/subscription), with flexible support for custom plugins.
https://the-guild.dev/graphql/codegen/
MIT License
10.83k stars 1.33k forks source link

Installed with `relay-compiler` will cause `npm i -D relay-compiler@latest` to install v12 #10049

Open stomvi opened 3 months ago

stomvi commented 3 months ago

Which packages are impacted by your issue?

@graphql-codegen/cli

Describe the bug

Installed with relay-compiler will cause npm i -D relay-compiler@latest to install v12 instead of the latest one, which is v17 now.

Your Example Website or App

Provide a minimal package.json below

Steps to Reproduce the Bug or Issue

The minimal package.json is

{
  "devDependencies": {
    "@graphql-codegen/cli": "^5.0.2",
    "relay-compiler": "^17.0.0"
  },
  "dependencies": {}
}

and

npm i && npx relay-compiler@latest --version

shows 12.0.0

Expected behavior

Should install relay-compiler@17.0.0 at this point, not v12.

Screenshots or Videos

No response

Platform

Codegen Config File

No response

Additional context

No response

stomvi commented 3 months ago

This may have something to do with issue #7825.

zeroliu commented 1 week ago

It happens to me as well. #7825 is closed but it's still happening with "@graphql-codegen/cli": "^5.0.2",

In package-lock.json, you can see

"node_modules/relay-compiler": {
      "version": "18.1.0",
      "resolved": "https://registry.npmjs.org/relay-compiler/-/relay-compiler-18.1.0.tgz",
      "integrity": "sha512-DGWIORIij0TIys/Xd5W/iToqTv7UcN6fqCPDqwYhLnfU7ukdK8rpk7f6RCYvhyZG71e7a1b3TLGOQY8A3XE3yg==",
      "dev": true,
      "bin": {
        "relay-compiler": "cli.js"
      }
    },

and

"@ardatan/relay-compiler": {
      "version": "12.0.0",
      "resolved": "https://registry.npmjs.org/@ardatan/relay-compiler/-/relay-compiler-12.0.0.tgz",
      "integrity": "sha512-9anThAaj1dQr6IGmzBMcfzOQKTa5artjuPmw8NYK/fiGEMjADbSguBY2FMDykt+QhilR3wc9VA/3yVju7JHg7Q==",
      "dev": true,
      ...

@ardatan/relay-compiler is a dependency of @graphql-tools/relay-operation-optimizer, which is a dependency of @graphql-codegen/visitor-plugin-common, which is dependency of @graphql-codegen/client-preset

I can work around the issue by specifying the latest relay node module cli.js

"relay": "node node_modules/relay-compiler/cli.js",