apollographql / apollographql/apollo-tooling

Typescript generation error "Cannot read property 'getType' of undefined"

Open
#580 16 comments 0 reactions 0 assignees View on GitHub
🤖 component - codegen
Dominant language
TypeScript
Stars
3k
Forks
460
PR merge metrics
No merged PRs in 30d

Description

Getting a confusing error when generating typescript files, as it is a bit in the bowels I'm not sure if I'm messing something up or if I'm using bad options. I can provide the schema if interested.

apollo codegen:generate --addTypename --target typescript graphql

√ Loading Apollo config
√ Scanning for GraphQL queries (458 found)
× Generating query files with 'typescript' target
→ Cannot read property 'getType' of undefined
TypeError: Cannot read property 'getType' of undefined
at Object.NamedType (C:/Users//AppData/Roaming/npm/node_modules/apollo/node_modules/graphql/validation/rules/KnownTypeNames.js:64:25)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported `apollo codegen:generate --addTypename --target typescript graphql` command with the relevant schema and queries. Inspect the TypeScript generation path and the reported `KnownTypeNames.js` failure at line 64, then confirm that generation completes without the `getType` error for the supplied case.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.