Skip to content

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

@saarnilauri

Description

@saarnilauri

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions