Correctly retrieve operation from request body
See gh-742
This commit is contained in:
@@ -105,9 +105,9 @@ public class WebGraphQlRequest extends DefaultExecutionGraphQlRequest implements
|
||||
|
||||
@Nullable
|
||||
private static String getOperation(Map<String, Object> body) {
|
||||
Object value = body.get("operation");
|
||||
Object value = body.get("operationName");
|
||||
if (value != null && !(value instanceof String)) {
|
||||
throw new ServerWebInputException("Invalid value for 'operation'");
|
||||
throw new ServerWebInputException("Invalid value for 'operationName'");
|
||||
}
|
||||
return (String) value;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class WebGraphQlRequestTests {
|
||||
void invalidBody() {
|
||||
testInvalidBody(Map.of());
|
||||
testInvalidBody(Map.of("query", Collections.emptyMap()));
|
||||
testInvalidBody(Map.of("query", "query { foo }", "operation", Collections.emptyMap()));
|
||||
testInvalidBody(Map.of("query", "query { foo }", "operationName", Collections.emptyMap()));
|
||||
testInvalidBody(Map.of("query", "query { foo }", "variables", "not-a-map"));
|
||||
testInvalidBody(Map.of("query", "query { foo }", "extensions", "not-a-map"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user