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

Types generation currently fails due duplicate "graphql" modules #12

Open
saarnilauri opened this issue Nov 6, 2024 · 0 comments
Open

Comments

@saarnilauri
Copy link

When using codegen.yml with setup for TypeScript as follows:

schema:
    - https://sivakka-fi.test/graphql:
          headers:
              x-graphql-lock-bypass: "ds02394fnjn234h"

documents:
    - "../assets/scripts//lib/apartment-archive/**/*.{ts,tsx,graphql,js}"
    - "../queries/*.graphql"
generates:
    ../assets/scripts/lib/apartment-archive/__gen__/types.d.ts:
        plugins:
            - typescript
            - typescript-operations
        config:
            enumsAsTypes: true
            enumValues: change-case#upperCase
            skipTypename: true

    ../persisted-query-ids/client.json:
        - graphql-codegen-persisted-query-ids:
              output: client

    ../persisted-query-ids/server.json:
        - graphql-codegen-persisted-query-ids:
              output: server

The types.d.ts file generation fails with following error:

> codegen
> gql-gen -o

✔ Parse Configuration
⚠ Generate outputs
  ❯ Generate to ../assets/scripts/lib/apartment-archive/__gen__/types.d.ts
    ✔ Load GraphQL schemas
    ✔ Load GraphQL documents
    ✖ Cannot use GraphQLScalarType "Boolean" 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 other
      relied on modules, use "resolutions" to ensure only one version is installed.
      https://yarnpkg.com/en/docs/selective-version-resolutions
      Duplicate "graphql" modules cannot be used at the same time since different
      versions may have different capabilities and behavior. The data from one
      version used in the function from another could produce confusing and
      spurious results.
  ✔ Generate to ../persisted-query-ids/client.json
  ✔ Generate to ../persisted-query-ids/server.json
  

The failure also seems to affect the generation of client.json and server.json files even the shell output says otherwise.

When I remove this part:

../assets/scripts/lib/apartment-archive/__gen__/types.d.ts:
        plugins:
            - typescript
            - typescript-operations
        config:
            enumsAsTypes: true
            enumValues: change-case#upperCase
            skipTypename: true
            

the generator runs as expected.

@saarnilauri saarnilauri changed the title Types generation currently fails due Types generation currently fails due duplicate "graphql" modules Nov 6, 2024
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

1 participant