apollo-tooling icon indicating copy to clipboard operation
apollo-tooling copied to clipboard

Error when generating typescript

Open JannesV opened this issue 9 years ago • 2 comments

I get the following error when generating types for typescript

TypeError: Cannot read property 'map' of undefined
    at fields.map.rootField (/usr/local/lib/node_modules/apollo-codegen/src/typescript/codeGeneration.js:153:36)
    at Array.map (<anonymous>)
    at interfaceDeclarationForOperation (/usr/local/lib/node_modules/apollo-codegen/src/typescript/codeGeneration.js:152:19)
    at Object.values.forEach.operation (/usr/local/lib/node_modules/apollo-codegen/src/typescript/codeGeneration.js:47:5)
    at Array.forEach (<anonymous>)
    at Object.generateSource (/usr/local/lib/node_modules/apollo-codegen/src/typescript/codeGeneration.js:45:37)
    at Object.generate (/usr/local/lib/node_modules/apollo-codegen/src/generate.ts:42:16)
    at Object.yargs.command.command.command.argv [as handler] (/usr/local/lib/node_modules/apollo-codegen/src/cli.js:183:7)
    at Object.self.runCommand (/usr/local/lib/node_modules/apollo-codegen/node_modules/yargs/lib/command.js:233:22)
    at Object.Yargs.self._parseArgs (/usr/local/lib/node_modules/apollo-codegen/node_modules/yargs/yargs.js:990:30)

when ran with the following command apollo-codegen generate src/**/*.graphql --schema src/graphql/schema.json --target ts --output src/graphql/schema.ts

It however runs without a problem if I change the target to flow

Version 0.16.5

JannesV avatar Aug 25 '17 13:08 JannesV

Hi @JannesV ,

Maybe related to this issue #195 ?

yuricamara avatar Aug 31 '17 22:08 yuricamara

Closing for now because this has likely been fixed as part of the rewrite in TypeScript. Feel free to ping for a re-open if you are still having this issue with the Apollo CLI!

shadaj avatar Jul 27 '18 23:07 shadaj