Graphql-code-generator: Yarn workspaces: Fix dependency resolution or document "nohoist"

Created on 14 Dec 2019  路  4Comments  路  Source: dotansimha/graphql-code-generator

Describe the bug
Dependency resolution doesn't seem to work correctly when using yarn workspaces:

 Found 1 error

  脳 generated/graphql.ts
    Unable to load template plugin matching 'typescript-resolvers'.
    Reason:
      Cannot find module '@graphql-codegen/core'
    Error: Unable to load template plugin matching typescript-resolvers

To Reproduce
Steps to reproduce the behavior:

  • Clone the following minimal repro
  • Install dependencies
  • Run yarn generate in packages/graphql

https://github.com/s-h-a-d-o-w/repro-codegen-workspaces

Expected behavior
Can run the script without errors.

Additional context
It does work when adding this to package.json:

  "workspaces": {
    "nohoist": [
      "@graphql-codegen/**"
    ]
  },

Which is why I would recommend that if a solution can't be found to document this here.

bug core waiting-for-release

Most helpful comment

@s-h-a-d-o-w Can you please try 1.11.3-alpha-48bfb197.95? It should work (make sure to use it without ~ or ^).
Also, change the package name in your reproduction to graphql-test or something, because it conflicts with the original graphql.

I tested it now and it seems to work.

All 4 comments

We had an issue with the dependencies mapping (one of the common packages was using core, it caused Yarn to install some of the deps twice). Thanks to @kamilkisiela, we found it.

I fixed it in: https://github.com/dotansimha/graphql-code-generator/pull/3386

Update: there is another issue related to graphql-toolkit, we are working on a fix (https://github.com/dotansimha/graphql-code-generator/pull/3392).

@s-h-a-d-o-w Can you please try 1.11.3-alpha-48bfb197.95? It should work (make sure to use it without ~ or ^).
Also, change the package name in your reproduction to graphql-test or something, because it conflicts with the original graphql.

I tested it now and it seems to work.

Updated the repo - looks good to me too, thanks! 馃槂馃憤

Fixed in v1.12.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NickClark picture NickClark  路  3Comments

bastman picture bastman  路  3Comments

SimenB picture SimenB  路  3Comments

fvisticot picture fvisticot  路  3Comments

iamdanthedev picture iamdanthedev  路  3Comments