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

Jest import looses doc.loc.source due to JSON.stringify #13

Open
emmanuelbuah opened this issue Aug 11, 2020 · 1 comment
Open

Jest import looses doc.loc.source due to JSON.stringify #13

emmanuelbuah opened this issue Aug 11, 2020 · 1 comment

Comments

@emmanuelbuah
Copy link

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

HriBB commented Nov 13, 2020

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.

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

2 participants