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

graphqlError.toJSON is not a function - need to upgrade graphql package #1385

Closed
cemsusal opened this issue Nov 20, 2022 · 2 comments
Closed
Labels
Question ❔ Not future request, proposal or bug issue Solved ✔️ The issue has been solved

Comments

@cemsusal
Copy link

Describe the Bug
I am using Apollo Server with expressMiddleware in combined with Type GraphQL. Following issue is happening in my environment.

I have tried following versions of graphql npm package resulting the same behavior:

  • 15.8.0
  • 15.7.0
  • 15.7.2

Seems like a bug in graphql package and resolved in later versions.
TypeGraphQL is not allowing me to use this version of graphql package: 16.6.0

To Reproduce
Any query with Apollo Server 4 returns following error message:

TypeError: graphqlError.toJSON is not a function at enrichError (file:///C:/Sources/seat-graph/node_modules/@apollo/server/src/errorNormalize.ts:84:30) at file:///C:/Sources/seat-graph/node_modules/@apollo/server/src/errorNormalize.ts:46:18 at Array.map (<anonymous>) at normalizeAndFormatErrors (file:///C:/Sources/seat-graph/node_modules/@apollo/server/src/errorNormalize.ts:39:29) at ApolloServer.errorResponse (file:///C:/Sources/seat-graph/node_modules/@apollo/server/src/ApolloServer.ts:1067:49) at ApolloServer.executeHTTPGraphQLRequest (file:///C:/Sources/seat-graph/node_modules/@apollo/server/src/ApolloServer.ts:1059:19) Unexpected error processing request: TypeError: graphqlError.toJSON is not a function

Expected Behavior
Queries should return the json data from resolvers.

Environment (please complete the following information):

  • OS: Windows 11
  • Node: v18.12.1
  • Package version: 1.1.1
  • TypeScript version: 4.9.3
@MichalLytek
Copy link
Owner

Apollo Server V4.0 has "Dropped support for versions of the graphql library prior to v16.6.0".
You need to use previous version or install type-graphql@2.0.0-beta.1.

@MichalLytek MichalLytek added Question ❔ Not future request, proposal or bug issue Solved ✔️ The issue has been solved labels Nov 20, 2022
@cemsusal
Copy link
Author

Thanks, @MichalLytek for the explanation.

I resolved my issue by upgrading type-graphql package to ^2.0.0-beta.1. Both Apollo Server and Type GraphQL are working fine now with higher versions of graphql package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question ❔ Not future request, proposal or bug issue Solved ✔️ The issue has been solved
Projects
None yet
Development

No branches or pull requests

2 participants