Skip to content

Commit 49d0ce4

Browse files
authored
Use error whitelist instead of blacklist to cover all yet unknown errors (#256)
1 parent e783d04 commit 49d0ce4

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

core/src/main/kotlin/org/neo4j/graphql/Translator.kt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package org.neo4j.graphql
22

3-
import graphql.ExceptionWhileDataFetching
4-
import graphql.ExecutionInput
5-
import graphql.GraphQL
6-
import graphql.InvalidSyntaxError
3+
import graphql.*
4+
import graphql.execution.NonNullableFieldWasNullError
75
import graphql.schema.GraphQLSchema
8-
import graphql.validation.ValidationError
96

107
class Translator(val schema: GraphQLSchema) {
118

@@ -27,8 +24,15 @@ class Translator(val schema: GraphQLSchema) {
2724
result.errors?.forEach {
2825
when (it) {
2926
is ExceptionWhileDataFetching -> throw it.exception
30-
is ValidationError -> throw InvalidQueryException(it)
31-
is InvalidSyntaxError -> throw InvalidQueryException(it)
27+
28+
is TypeMismatchError, // expected since we return cypher here instead of the correct json
29+
is NonNullableFieldWasNullError, // expected since the returned cypher does not match the shape of the graphql type
30+
is SerializationError // expected since the returned cypher does not match the shape of the graphql type
31+
-> {
32+
// ignore
33+
}
34+
// generic error handling
35+
is GraphQLError -> throw InvalidQueryException(it)
3236
}
3337
}
3438

0 commit comments

Comments
 (0)