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

cli fatal crash when using skipDocumentsValidation #8389

Closed
Diizzayy opened this issue Sep 27, 2022 · 1 comment
Closed

cli fatal crash when using skipDocumentsValidation #8389

Diizzayy opened this issue Sep 27, 2022 · 1 comment

Comments

@Diizzayy
Copy link
Contributor

Describe the bug

When utilizing @graphql-codegen/cli, I've noticed instances with multiple schema where using skipDocumentsValidation: true, results in the following error:

 ERROR  Cannot read properties of undefined (reading 'name')                                                           09:37:55

  at executeCodegen (node_modules/.pnpm/@graphql-codegen+cli@2.12.1_graphql@16.6.0/node_modules/@graphql-codegen/cli/cjs/codegen.js:326:24)
  at async generate (node_modules/.pnpm/@graphql-codegen+cli@2.12.1_graphql@16.6.0/node_modules/@graphql-codegen/cli/cjs/generate-and-save.js:91:25)
  at async _default (src/generate.ts:76:10)
  at async generateGqlTypes (src/module.ts:142:22)
  at async setup (src/module.ts:208:5)
  at async Object.normalizedModule (node_modules/.pnpm/@nuxt+kit@3.0.0-rc.11/node_modules/@nuxt/kit/dist/index.mjs:637:5)
  at async installModule (node_modules/.pnpm/@nuxt+kit@3.0.0-rc.11/node_modules/@nuxt/kit/dist/index.mjs:456:3)
  at async initNuxt (node_modules/.pnpm/nuxt@3.0.0-rc.11_eslint@8.23.1/node_modules/nuxt/dist/index.mjs:1606:7)
  at async loadNuxt (node_modules/.pnpm/nuxt@3.0.0-rc.11_eslint@8.23.1/node_modules/nuxt/dist/index.mjs:1635:5)
  at async loadNuxt (node_modules/.pnpm/@nuxt+kit@3.0.0-rc.11/node_modules/@nuxt/kit/dist/index.mjs:732:19)
  
  TypeError: Cannot read properties of undefined (reading 'name')
  at node_modules/.pnpm/graphql@16.6.0/node_modules/graphql/type/introspection.js:618:51
  at Array.some (<anonymous>)
  at isIntrospectionType (node_modules/.pnpm/graphql@16.6.0/node_modules/graphql/type/introspection.js:618:29)
  at Object.Field (node_modules/.pnpm/@graphql-codegen+typescript@2.7.3_graphql@16.6.0/node_modules/@graphql-codegen/typescript/cjs/index.js:45:51)
  at Object.enter (node_modules/.pnpm/graphql@16.6.0/node_modules/graphql/utilities/TypeInfo.js:391:27)
  at visit (node_modules/.pnpm/graphql@16.6.0/node_modules/graphql/language/visitor.js:197:21)
  at node_modules/.pnpm/@graphql-codegen+typescript@2.7.3_graphql@16.6.0/node_modules/@graphql-codegen/typescript/cjs/index.js:50:50
  at Array.forEach (<anonymous>)
  at includeIntrospectionTypesDefinitions (node_modules/.pnpm/@graphql-codegen+typescript@2.7.3_graphql@16.6.0/node_modules/@graphql-codegen/typescript/cjs/index.js:50:15)
  at Object.plugin (node_modules/.pnpm/@graphql-codegen+typescript@2.7.3_graphql@16.6.0/node_modules/@graphql-codegen/typescript/cjs/index.js:18:38)

I've traced this issue back to this line /packages/plugins/typescript/typescript/src/index.ts#L68, it occurs when the type variables is undefined yet still passed to the isIntrospectionType function

Your Example Website or App

https://github.com/Diizzayy/cgenbug

Steps to Reproduce the Bug or Issue

  1. Clone the reproduction repo i've provided
  2. run yarn install
  3. run yarn start

Expected behavior

the codgen is supposed to properly skip document validation

Screenshots or Videos

No response

Platform

  • Operating System: Darwin
  • Node Version: v18.9.0
  • Package Manager: yarn@1.22.19
  • graphql version: 16.6.0
  • @graphql-codegen/* version(s): 2.7.3

Codegen Config File

No response

Additional context

No response

@charlypoly
Copy link
Contributor

@Diizzayy, thank you again for your contribution!

Your fix is now available in @graphql-codegen/typescript@2.8.0 📦

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