Skip to content
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

Fix classification type in GraphQLErrorExtensions #1802

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ data class GraphQLErrorExtensions(
@JsonProperty val errorDetail: String? = null,
@JsonProperty val origin: String = "",
@JsonProperty val debugInfo: GraphQLErrorDebugInfo = GraphQLErrorDebugInfo(),
@JsonProperty val classification: String = ""
@JsonProperty val classification: Any = ""
)

data class GraphQLErrorDebugInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.netflix.graphql.dgs.client

import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.Assertions.fail
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.params.ParameterizedTest
Expand Down Expand Up @@ -257,4 +258,32 @@ class GraphQLResponseTest {
val result = response.dataAsObject(Response::class.java)
assertEquals(Response(submitReview = mapOf("submittedBy" to "[email protected]")), result)
}

@Test
fun testObjectErrorClassification() {
val response = GraphQLResponse(
"""{
"data": null,
"errors": [{
"message": "Validation failed",
"path": ["shows", 12],
"extensions": {
"errorType": "INTERNAL",
"classification": {
"type": "ExtendedValidationError",
"validatedPath": ["shows", "title"]
}
}
}]
}
""".trimIndent()
)
val error = response.errors.singleOrNull() ?: fail("Expected single error on response: $response")
assertThat(error.message).isEqualTo("Validation failed")
assertThat(error.path).isEqualTo(listOf("shows", 12))

val extensions = error.extensions ?: fail("Expected non-null extensions on error: $error")
assertThat(extensions.errorType).isEqualTo(ErrorType.INTERNAL)
assertThat(extensions.classification).isEqualTo(mapOf("type" to "ExtendedValidationError", "validatedPath" to listOf("shows", "title")))
}
}
Loading