ardatan/graphql-toolkit

TypeError: Cannot read property 'data' of null

feelinwavy opened this issue · 0 comments

Hey there, I ran into a problem when trying to load schema for graphql-codegen using Glob Expression pattern.
I can not get why, but sometimes let loaded (node_modules/@graphql-toolkit/code-file-loader/index.cjs.js) from line 145 returns null

`Failed to load schema from ./src/schema/**/*.ts:

    Cannot read property 'data' of null
    TypeError: Cannot read property 'data' of null
at CodeFileLoader.load (/Users/evgeny/projects/yeardo/back/node_modules/@graphql-toolkit/code-file-loader/index.cjs.js:145:20)
at processTicksAndRejections (internal/process/task_queues.js:94:5)
at loadSingleFile (/Users/evgeny/projects/yeardo/back/node_modules/@graphql-toolkit/core/index.cjs.js:653:31)
at /Users/evgeny/projects/yeardo/back/node_modules/@graphql-toolkit/core/index.cjs.js:596:42
at async Promise.all (index 1)
at /Users/evgeny/projects/yeardo/back/node_modules/@graphql-toolkit/core/index.cjs.js:559:13
at async Promise.all (index 0)
at loadTypedefs (/Users/evgeny/projects/yeardo/back/node_modules/@graphql-toolkit/core/index.cjs.js:603:5)
at Object.loadSchema (/Users/evgeny/projects/yeardo/back/node_modules/@graphql-toolkit/core/index.cjs.js:676:21)
at loadSchema (/Users/evgeny/projects/yeardo/back/node_modules/@graphql-codegen/cli/bin.js:342:24)
at /Users/evgeny/projects/yeardo/back/node_modules/@graphql-codegen/cli/bin.js:723:55
at Task.task (/Users/evgeny/projects/yeardo/back/node_modules/@graphql-codegen/cli/bin.js:582:17)`

Found a solution - Wrapping code from node_modules/@graphql-toolkit/code-file-loader/index.cjs.js lines 145 - 170 inside an if statement helps.

This happened after updating @graphql-codegen/cli from 1.9.1 to 1.11.2