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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for graphql 16: GraphQLNonNull cannot be invoked without 'new' #1009
Comments
You may need to additionally patch (add
Something a bit like this... diff --git a/node_modules/nexus/dist-esm/builder.js b/node_modules/nexus/dist-esm/builder.js
index 202ad18..8894254 100644
--- a/node_modules/nexus/dist-esm/builder.js
+++ b/node_modules/nexus/dist-esm/builder.js
@@ -649,7 +649,7 @@ export class SchemaBuilder {
name: 'Query',
fields: {
ok: {
- type: GraphQLNonNull(GraphQLBoolean),
+ type: new GraphQLNonNull(GraphQLBoolean),
resolve: () => true,
},
},
diff --git a/node_modules/nexus/dist-esm/definitions/wrapping.js b/node_modules/nexus/dist-esm/definitions/wrapping.js
index 252c38c..72d18ee 100644
--- a/node_modules/nexus/dist-esm/definitions/wrapping.js
+++ b/node_modules/nexus/dist-esm/definitions/wrapping.js
@@ -138,11 +138,11 @@ export function rewrapAsGraphQLType(baseType, wrapping) {
let finalType = 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 {
diff --git a/node_modules/nexus/dist/builder.js b/node_modules/nexus/dist/builder.js
index b410a20..199ca56 100644
--- a/node_modules/nexus/dist/builder.js
+++ b/node_modules/nexus/dist/builder.js
@@ -652,7 +652,7 @@ class SchemaBuilder {
name: 'Query',
fields: {
ok: {
- type: graphql_1.GraphQLNonNull(graphql_1.GraphQLBoolean),
+ type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLBoolean),
resolve: () => true,
},
},
diff --git a/node_modules/nexus/dist/definitions/wrapping.js b/node_modules/nexus/dist/definitions/wrapping.js
index 2369cd2..7526942 100644
--- a/node_modules/nexus/dist/definitions/wrapping.js
+++ b/node_modules/nexus/dist/definitions/wrapping.js
@@ -165,11 +165,11 @@ function rewrapAsGraphQLType(baseType, wrapping) {
let finalType = baseType;
wrapping.forEach((wrap) => {
if (wrap === 'List') {
- finalType = graphql_1.GraphQLList(finalType);
+ finalType = new graphql_1.GraphQLList(finalType);
}
else if (wrap === 'NonNull') {
if (!graphql_1.isNonNullType(finalType)) {
- finalType = graphql_1.GraphQLNonNull(finalType);
+ finalType = new graphql_1.GraphQLNonNull(finalType);
}
}
else {
diff --git a/node_modules/nexus/src/builder.ts b/node_modules/nexus/src/builder.ts
index f771ead..06ae929 100644
--- a/node_modules/nexus/src/builder.ts
+++ b/node_modules/nexus/src/builder.ts
@@ -1096,7 +1096,7 @@ export class SchemaBuilder {
name: 'Query',
fields: {
ok: {
- type: GraphQLNonNull(GraphQLBoolean),
+ type: new GraphQLNonNull(GraphQLBoolean),
resolve: () => true,
},
},
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) |
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. |
Should this be covered by a peer dep? It's probably a trade off in developer experience but it would have prevented this bug. edit never mind we already have a peer dep and it doesn't cover graphql 16. |
Any status on this issue? |
When next release for fix this ? |
It's a beautiful thing @tgriesser thank you 馃檹 |
Hi! 馃憢
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
Here is the diff that solved my problem:
It happened because of this PR graphql/graphql-js#2906
The text was updated successfully, but these errors were encountered: