Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with yarn 4 workspaces #9864

Closed
platzhersh opened this issue Feb 22, 2024 · 4 comments
Closed

Issue with yarn 4 workspaces #9864

platzhersh opened this issue Feb 22, 2024 · 4 comments

Comments

@platzhersh
Copy link

platzhersh commented Feb 22, 2024

Which packages are impacted by your issue?

@graphql-codegen/cli

Describe the bug

After migrating from yarn, to yarn 4 with workspaces, the codegen does not work anymore:

✔ Parse Configuration
⚠ Generate outputs
  ❯ Generate to src/queries/generatedGQLTypes.ts
    ✔ Load GraphQL schemas
    ✔ Load GraphQL documents
    ✖ Cannot use GraphQLNonNull "join__Graph!" 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 oth…
      relied on modules, use "resolutions" to ensure only one version is instal…
      https://yarnpkg.com/en/docs/selective-version-resolutions
      Duplicate "graphql" modules cannot be used at the same time since differe…
      versions may have different capabilities and behavior. The data from one
      version used in the function from another could produce confusing and
      spurious results.
$yarn why graphql
├─ @types/graphql-depth-limit@npm:1.1.5
│  └─ graphql@npm:16.8.1 (via npm:16.8.1)
│
└─ spectaql@npm:2.3.0
   └─ graphql@npm:16.8.1 (via npm:16.8.1)

Your Example Website or App

Steps to Reproduce the Bug or Issue

Expected behavior

I'd expect codegen to be ok with the available graphql package

Screenshots or Videos

grafik

Platform

  • OS: macOS, m1

  • NodeJS: 20.4.0

  • graphql version: 16.8.1

  • @graphql-codegen/* version(s): 5.0.2

      "@graphql-codegen/cli": "5.0.2",
      "@graphql-codegen/typed-document-node": "5.0.5",
      "@graphql-codegen/typescript": "4.0.5",
      "@graphql-codegen/typescript-operations": "4.1.3",
    

Codegen Config File

overwrite: true
schema: 'supergraph.graphql'
documents: 'src/queries/**/*.graphql'
generates:
src/queries/generatedGQLTypes.ts:
plugins:
- 'typescript'
- 'typescript-operations'
- 'typed-document-node'
config:
avoidOptionals: false
onlyOperationTypes: false
omitOperationSuffix: false # has to be set to false for now because otherwise duplicate types will be generated
dedupeFragments: true
scalars:
DateTime: string

Additional context

I will try to create a sandbox later

@saihaj
Copy link
Collaborator

saihaj commented Feb 22, 2024

can you try yarn resolutions and force only 1 package of graphql?

@platzhersh
Copy link
Author

I have already added a resolutions:

    "resolutions": {
        "graphql": "16.8.1"
    },

it didn't help unfortunately

@saihaj
Copy link
Collaborator

saihaj commented Feb 23, 2024

Can you please share a minimal reproduction. You can either use StackBlitz, CodeSandbox or a public GitHub repo.

@platzhersh
Copy link
Author

platzhersh commented Feb 23, 2024

Thank you for insisting, I just did that, could not reproduce it.

Realised that I had some stale node_modules in my sub-workspaces that were causing the issue.

No bug therefore, just a clumsy dev - me :-)

#lessonslearned

Thanks for your quick feedback and your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants