Fix Queries Containing % (#766)

This commit is contained in:
Mitchell Syer
2023-11-07 18:11:38 -05:00
committed by GitHub
parent 460fc235e3
commit 50cd0c4e10

View File

@@ -20,9 +20,17 @@ class JavalinGraphQLRequestParser : GraphQLRequestParser<Context> {
@Suppress("PARAMETER_NAME_CHANGED_ON_OVERRIDE", "UNCHECKED_CAST") @Suppress("PARAMETER_NAME_CHANGED_ON_OVERRIDE", "UNCHECKED_CAST")
override suspend fun parseRequest(context: Context): GraphQLServerRequest? { override suspend fun parseRequest(context: Context): GraphQLServerRequest? {
return try { return try {
val contentType = context.contentType()
val formParam = val formParam =
if (
contentType?.contains("application/x-www-form-urlencoded") == true ||
contentType?.contains("multipart/form-data") == true
) {
context.formParam("operations") context.formParam("operations")
?: return context.bodyAsClass(GraphQLServerRequest::class.java) ?: throw IllegalArgumentException("Cannot find 'operations' body")
} else {
return context.bodyAsClass(GraphQLServerRequest::class.java)
}
val request = val request =
context.jsonMapper().fromJsonString( context.jsonMapper().fromJsonString(