Cannot read property 'getFields' of undefined
empty-jack opened this issue · 2 comments
empty-jack commented
Error Example:
gqlg --schemaFilePath ./schema.graphql --destDirPath ./gqlg-new --depthLimit 2
description: Mutation
/usr/local/lib/node_modules/gql-generator/index.js:177
const field = gqlSchema.getType(description).getFields()[type];
^
TypeError: Cannot read property 'getFields' of undefined
at /usr/local/lib/node_modules/gql-generator/index.js:177:49
at Array.forEach (<anonymous>)
at generateFile (/usr/local/lib/node_modules/gql-generator/index.js:176:20)
at Object.<anonymous> (/usr/local/lib/node_modules/gql-generator/index.js:193:3)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:839:10)
at internal/main/run_main_module.js:17:11
If GQL Schema looks like this:
schema {
query: RootQueryType
mutation: RootMutationType
}
...
query: RootQueryType
mutation: RootMutationType
}
type RootQueryType {
asset(id: ID): Asset
...
* That's really popular example of schemas.
Then you will see error as shown above cause description
filed in index.js get values from the hardcoded list: Query,Mutation,Subscription
and doesn't check custom query names.
mahald commented
Just run into the same issue. Now just added a step to replace RootQueryType with Query and RootMutationType with Mutation in the File and all works fine. Would really be nice to be supported.
justenau commented
I created a PR to solve this issue, hopefully it will get approved soon.