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

TypeError: Cannot read property 'name' of undefined with simple typescript setup #6916

Closed
samuela opened this issue Oct 27, 2021 · 2 comments

Comments

@samuela
Copy link

samuela commented Oct 27, 2021

Describe the bug
I'm trying to follow the intro tutorial but I'm hitting up on an error:

 Found 1 error

  ✖ src/generated/hasura-types.d.ts
    TypeError: Cannot read property 'name' of undefined
        at /Users/skainswo/dev/cuddlefish/vscode-extension/node_modules/graphql/type/introspection.js:622:17
        at Array.some (<anonymous>)
        at Object.isIntrospectionType (/Users/skainswo/dev/cuddlefish/vscode-extension/node_modules/graphql/type
/introspection.js:620:29)
...

You can check out the full log here: https://gist.github.com/samuela/93253c407de353d27ea8224a96757d73.

How does one set up a basic TS graphql-code-generator configuration?

To Reproduce
Steps to reproduce the behavior:

  1. My GraphQL schema:
<long, complicated, and doesn't seem to be relevant. happy to provide on request tho!>
  1. My GraphQL operations:
# src/queries.graphql
mutation StartThread(
  $repoIds: [String!]!
  $commitHash: String!
  $filePath: String!
  $lineNumber: Int!
  $body: String!
) {
  StartThread(
    repoIds: $repoIds
    commitHash: $commitHash
    filePath: $filePath
    lineNumber: $lineNumber
    body: $body
  )
}
  1. My codegen.yml config file:
overwrite: true
schema: "http://localhost:8080/v1/graphql"
documents: "src/**/*.graphql"
generates:
  src/generated/hasura-types.d.ts:
    plugins:
      - "typescript"

Expected behavior
The setup tutorial to "just work."

Environment:

  • OS: macOS 11.6
  • @graphql-codegen/...:
		"@graphql-codegen/cli": "2.2.1",
		"@graphql-codegen/introspection": "2.1.0",
		"@graphql-codegen/typescript": "^2.2.4",
		"@graphql-codegen/typescript-document-nodes": "2.1.6",
		"@graphql-codegen/typescript-graphql-files-modules": "2.1.0",
		"@graphql-codegen/typescript-operations": "2.1.8",
  • NodeJS: v15.14.0

Additional context

@samuela
Copy link
Author

samuela commented Oct 27, 2021

Possibly relevant: "graphql": "^15.6.1"

@samuela
Copy link
Author

samuela commented Oct 29, 2021

Actually, I believe that this was due to a weird GraphQL schema. I recently changed the schema slightly in a way that should've made no difference and the error has disappeared. I'll close for now, and open a new issue if I'm able to find a concrete reproduction.

@samuela samuela closed this as completed Oct 29, 2021
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