You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.
I am writing this to discuss an issue I am facing once in a while. This is more an open discussion on the feasibility of this feature, but I think this is something that the framework would greatly benefit to get.
At the moment, it is possible to declare different nullability in your Kotlin Class compared to your GraphQL Schema
For Instance
typeQuery {
test(target: String) : Boolean # <= target and output are nullable
}
could be implemented by the following resolver, and it would boot properly without any error
However, when performing the following GraphQL Query,
query {
test(target: null)
}
I would get the following error
java.lang.NullPointerException: Parameter specified as non-null is null: method com.test.graphql.GraphQLTest.test, parameter target
at com.test.graphql.GraphQLTest.test(GraphQLTest.kt)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at graphql.kickstart.tools.resolver.MethodFieldResolverDataFetcher.get(MethodFieldResolver.kt:261)
at graphql.schema.DataFetcherFactories.lambda$wrapDataFetcher$2(DataFetcherFactories.java:37)
at graphql.validation.schemawiring.FieldValidatorDataFetcher.get(FieldValidatorDataFetcher.java:54)
at graphql.execution.ExecutionStrategy.fetchField(ExecutionStrategy.java:279)
at graphql.execution.ExecutionStrategy.resolveFieldWithInfo(ExecutionStrategy.java:210)
....
Which inevitably returns an InternalError
Describe the solution you'd like
For me, an ideal solution would be that Spring-GraphQL would perform nullability checks for Kotlin classes at boot time (could also be done for java with @Nullable, but again to discuss), the same way it already validate the schema in many different ways.
Thank you for your help, and mostly, thanks a lot for your incredible work on this framework!
The text was updated successfully, but these errors were encountered:
I am writing this to discuss an issue I am facing once in a while. This is more an open discussion on the feasibility of this feature, but I think this is something that the framework would greatly benefit to get.
At the moment, it is possible to declare different nullability in your Kotlin Class compared to your GraphQL Schema
For Instance
could be implemented by the following resolver, and it would boot properly without any error
However, when performing the following GraphQL Query,
I would get the following error
Which inevitably returns an
InternalError
Describe the solution you'd like
For me, an ideal solution would be that Spring-GraphQL would perform nullability checks for Kotlin classes at boot time (could also be done for java with
@Nullable
, but again to discuss), the same way it already validate the schema in many different ways.Thank you for your help, and mostly, thanks a lot for your incredible work on this framework!
The text was updated successfully, but these errors were encountered: