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

Introspection plugin unmet @babel/runtime dependency #10266

Open
reeko opened this issue Jan 21, 2025 · 1 comment
Open

Introspection plugin unmet @babel/runtime dependency #10266

reeko opened this issue Jan 21, 2025 · 1 comment
Labels
waiting-for-answer Waiting for answer from author

Comments

@reeko
Copy link

reeko commented Jan 21, 2025

Which packages are impacted by your issue?

@graphql-codegen/cli, @graphql-codegen/introspection

Describe the bug

I get an error when running introspection. After adding some logs to node_modules/@graphql-codegen/cli/cjs/plugins.js, I get the following error:

Cannot find module '@babel/runtime/helpers/createForOfIteratorHelper'

After installing the @babel/runtime package, the introspection works fine.

Full error:

❯ Generate outputs
  ❯ Generate to ./src/gql/example/introspection.example.json
    ✔ Load GraphQL schemas
    ✔ Load GraphQL documents
    ⠹ Generate
  ❯ Generate to ./src/gql/example/schema.example.graphql
    ✔ Load GraphQL schemas
    ✔ Load GraphQL documents
    ⠹ Generate
GQL-ERROR: @graphql-codegen/introspection
GQL-ERROR: Error: Cannot find module '@babel/runtime/helpers/createForOfIteratorHelper'
Require stack:
- project/node_modules/@ardatan/relay-compiler/lib/core/CompilerError.js
- project/node_modules/@ardatan/relay-compiler/lib/core/CompilerContext.js
- project/node_modules/@graphql-tools/relay-operation-optimizer/cjs/index.js
- project/node_modules/@graphql-codegen/visitor-plugin-common/cjs/optimize-operations.js
- project/node_modules/@graphql-codegen/visitor-plugin-common/cjs/index.js
- project/node_modules/@graphql-codegen/introspection/cjs/index.js
- project/node_modules/@graphql-codegen/cli/cjs/codegen.js
- project/node_modules/@graphql-codegen/cli/cjs/generate-and-save.js
- project/node_modules/@graphql-codegen/cli/cjs/cli.js
- project/node_modules/@graphql-codegen/cli/cjs/bin.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1225:15)
    at Module._load (node:internal/modules/cjs/loader:1051:27)
    at Module.require (node:internal/modules/cjs/loader:1311:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (project/node_modules/@ardatan/relay-compiler/lib/core/CompilerError.js:15:58)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Module._load (node:internal/modules/cjs/loader:1104:12)
    at Module.require (node:internal/modules/cjs/loader:1311:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'project/node_modules/@ardatan/relay-compiler/lib/core/CompilerError.js',
    'project/node_modules/@ardatan/relay-compiler/lib/core/CompilerContext.js',
    'project/node_modules/@graphql-tools/relay-operation-optimizer/cjs/index.js',
    'project/node_modules/@graphql-codegen/visitor-plugin-common/cjs/optimize-operations.js',
    'project/node_modules/@graphql-codegen/visitor-plugin-common/cjs/index.js',
    'project/node_modules/@graphql-codegen/introspection/cjs/index.js',
    'project/node_modules/@graphql-codegen/cli/cjs/codegen.js',
    'project/node_modules/@graphql-codegen/cli/cjs/generate-and-save.js',
    'project/node_modules/@graphql-codegen/cli/cjs/cli.js',
    'project/node_modules/@graphql-codegen/cli/cjs/bin.js'
  ]
}

Node version v20.18.1

Installed packages:

"@graphql-codegen/add": "^5.0.3",
"@graphql-codegen/cli": "^5.0.3",
"@graphql-codegen/client-preset": "^4.5.1",
"@graphql-codegen/fragment-matcher": "^5.0.2",
"@graphql-codegen/import-types-preset": "^3.0.0",
"@graphql-codegen/introspection": "^4.0.3",
"@graphql-codegen/near-operation-file-preset": "^3.0.0",
"@graphql-codegen/schema-ast": "^4.1.0",
"@graphql-codegen/typed-document-node": "^5.0.12",
"@graphql-codegen/typescript": "^4.1.2",
"@graphql-codegen/typescript-apollo-client-helpers": "^3.0.0",
"@graphql-codegen/typescript-document-nodes": "4.0.12",
"@graphql-codegen/typescript-graphql-files-modules": "3.0.0",
"@graphql-codegen/typescript-operations": "4.4.0",
"@graphql-codegen/typescript-vue-apollo": "^4.1.1",
"@graphql-typed-document-node/core": "^3.2.0",
"graphql": "^16.10.0",
"graphql-scalars": "^1.24.0",

// Adding babel after error
"@babel/runtime": "^7.26.0"

codegen.ts

import type { CodegenConfig } from "@graphql-codegen/cli";

const config: CodegenConfig = {
  overwrite: true,
  schema:
    process.env.VITE_APP_SERVICES_BACKEND_API_URL,
  documents: ["src/**/*.example.graphql"],
  ignoreNoDocuments: true,
  generates: {
    "./src/gql/example/introspection.example.json": {
      hooks: {
        afterOneFileWrite: ["prettier --write"],
      },
      plugins: ["introspection"],
      config: {
        minify: false,
        schemaDescription: true,
      },
    },
  },
};

export default config;

Your Example Website or App

https://example.com

Steps to Reproduce the Bug or Issue

  1. Remove @babel/runtime from package.json
  2. Run codgen:introspection

Expected behavior

No error.

Screenshots or Videos

No response

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • NodeJS: [e.g. 18.5.0]
  • graphql version: [e.g. 16.3.0]
  • @graphql-codegen/* version(s): [e.g. 2.6.2]

Codegen Config File

No response

Additional context

No response

@eddeee888
Copy link
Collaborator

Hi @reeko ,

Could you please provide an example reproducible using GitHub, Stackblitz or CodeSandbox?

I've tried following the steps here but I don't see the issue - which usually means it's a repo-specific problem.

@eddeee888 eddeee888 added the waiting-for-answer Waiting for answer from author label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-for-answer Waiting for answer from author
Projects
None yet
Development

No branches or pull requests

2 participants