Skip to content

Commit 046cef6

Browse files
committed
fix: correctly retrieve operation from request body
1 parent 6068e64 commit 046cef6

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

spring-graphql/src/main/java/org/springframework/graphql/server/WebGraphQlRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ private static String getQuery(Map<String, Object> body) {
105105

106106
@Nullable
107107
private static String getOperation(Map<String, Object> body) {
108-
Object value = body.get("operation");
108+
Object value = body.get("operationName");
109109
if (value != null && !(value instanceof String)) {
110-
throw new ServerWebInputException("Invalid value for 'operation'");
110+
throw new ServerWebInputException("Invalid value for 'operationName'");
111111
}
112112
return (String) value;
113113
}

spring-graphql/src/test/java/org/springframework/graphql/server/WebGraphQlRequestTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class WebGraphQlRequestTests {
3939
void invalidBody() {
4040
testInvalidBody(Map.of());
4141
testInvalidBody(Map.of("query", Collections.emptyMap()));
42-
testInvalidBody(Map.of("query", "query { foo }", "operation", Collections.emptyMap()));
42+
testInvalidBody(Map.of("query", "query { foo }", "operationName", Collections.emptyMap()));
4343
testInvalidBody(Map.of("query", "query { foo }", "variables", "not-a-map"));
4444
testInvalidBody(Map.of("query", "query { foo }", "extensions", "not-a-map"));
4545
}

0 commit comments

Comments
 (0)