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

Cannot read property 'getFields' of undefined #27

Open
empty-jack opened this issue Oct 22, 2019 · 2 comments
Open

Cannot read property 'getFields' of undefined #27

empty-jack opened this issue Oct 22, 2019 · 2 comments

Comments

@empty-jack
Copy link

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
Copy link

mahald commented Apr 12, 2020

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
Copy link
Contributor

justenau commented Apr 6, 2022

I created a PR to solve this issue, hopefully it will get approved soon.

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

3 participants