Fix for graphql 16: GraphQLNonNull cannot be invoked without 'new'
See original GitHub issueHi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch nexus@1.1.0
for the project I’m working on.
Nexus wasn’t working anymore with graphql version 16.0.0 nor 16.0.1
My error message was
Class constructor GraphQLNonNull cannot be invoked without 'new'
Here is the diff that solved my problem:
diff --git a/node_modules/nexus/src/definitions/wrapping.ts b/node_modules/nexus/src/definitions/wrapping.ts
index 9af7565..c60aa00 100644
--- a/node_modules/nexus/src/definitions/wrapping.ts
+++ b/node_modules/nexus/src/definitions/wrapping.ts
@@ -246,10 +246,10 @@ export function rewrapAsGraphQLType(baseType: GraphQLNamedType, wrapping: NexusF
let finalType: GraphQLType = baseType
wrapping.forEach((wrap) => {
if (wrap === 'List') {
- finalType = GraphQLList(finalType)
+ finalType = new GraphQLList(finalType)
} else if (wrap === 'NonNull') {
if (!isNonNullType(finalType)) {
- finalType = GraphQLNonNull(finalType)
+ finalType = new GraphQLNonNull(finalType)
}
} else {
throw new Unreachable(wrap)
It happened because of this PR https://github.com/graphql/graphql-js/pull/2906
Issue Analytics
- State:
- Created 2 years ago
- Reactions:11
- Comments:6 (3 by maintainers)
Top Results From Across the Web
TypeError: Class constructor GraphQLNonNull cannot be ...
In my case 14.5.8 (from GitHub nexus example) workes correctly There's pull-request with fixes for graphql 16+ version: ...
Read more >graphql/type
class GraphQLNonNull. A type wrapper around other types that represents a non-null version of those types. Predicates. function isInputType
Read more >graphql - npm
This defines a simple schema, with one type and one field, that resolves to a fixed value. The resolve function can return a...
Read more >Javascript ES6 TypeError Class constructor Client cannot be ...
When I try to execute nodemon command I always see this error TypeError: Class constructor Client cannot be invoked without 'new'.
Read more >Migrating to Apollo Server 4 - Apollo GraphQL Docs
There are no integration-specific subclasses in Apollo Server 4. Instead, there's a single ApolloServer class with a single API that all integrations use....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks, I had started on this in #977 but now that it’s officially released I’ll look to get this landed, hopefully by this weekend.
You may need to additionally patch (add
new
) in the following places, if you’re temporarily patching it so it works for your project.Something a bit like this…