Skip to content

Use error whitelist instead of blacklist to cover all yet unknown errors #256

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

Merged
merged 1 commit into from
Nov 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions core/src/main/kotlin/org/neo4j/graphql/Translator.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package org.neo4j.graphql

import graphql.ExceptionWhileDataFetching
import graphql.ExecutionInput
import graphql.GraphQL
import graphql.InvalidSyntaxError
import graphql.*
import graphql.execution.NonNullableFieldWasNullError
import graphql.schema.GraphQLSchema
import graphql.validation.ValidationError

class Translator(val schema: GraphQLSchema) {

Expand All @@ -27,8 +24,15 @@ class Translator(val schema: GraphQLSchema) {
result.errors?.forEach {
when (it) {
is ExceptionWhileDataFetching -> throw it.exception
is ValidationError -> throw InvalidQueryException(it)
is InvalidSyntaxError -> throw InvalidQueryException(it)

is TypeMismatchError, // expected since we return cypher here instead of the correct json
is NonNullableFieldWasNullError, // expected since the returned cypher does not match the shape of the graphql type
is SerializationError // expected since the returned cypher does not match the shape of the graphql type
-> {
// ignore
}
// generic error handling
is GraphQLError -> throw InvalidQueryException(it)
}
}

Expand Down