Jest import looses doc.loc.source due to JSON.stringify
Opened this issue · 1 comments
emmanuelbuah commented
Per issue laid out in apollographql/graphql-tag#115, stringifying gql DocumentNode loose doc.loc.source property since its not enumerable anymore.
Looking at the code, jest import utilizes stringification which makes it so the returned DocuemntNote encounters errors such as apollographql/graphql-tag#64 when used with graphql-tag.
I'd recommend patching the jest code to apply the same/similar fix in apollographql/graphql-tag#65 to address the issue.
HriBB commented
I'm getting a similar error with graphql-import-node
and jest
:
Unable to create News schema!
Cannot read property 'prev' of undefined
TypeError: Cannot read property 'prev' of undefined
at getLeadingCommentBlock (../../node_modules/graphql/utilities/extendSchema.js:713:30)
at getDescription (../../node_modules/graphql/utilities/extendSchema.js:694:20)
at buildType (../../node_modules/graphql/utilities/extendSchema.js:546:23)
at extendSchemaImpl (../../node_modules/graphql/utilities/extendSchema.js:138:120)
at Object.buildASTSchema (../../node_modules/graphql/utilities/buildASTSchema.js:56:51)
at buildSchemaFromTypeDefinitions (../../dist/schema/src/buildSchemaFromTypeDefinitions.js:9:18)
at Object.makeExecutableSchema (../../dist/schema/src/makeExecutableSchema.js:64:18)
at Object.<anonymous>.exports.createSchema (src/news/createSchema.ts:55:20)
at Object.<anonymous> (test/app.test.ts:13:22)
at Object.<anonymous>.exports.createSchema (src/news/createSchema.ts:61:11)
at Object.<anonymous> (test/app.test.ts:13:22)
Error appears only in tests. If I use gql
it works.