Skip to content

Commit f83708c

Browse files
authored
Fix non-query compound requests #477
Use the first request's type to match all others against, as the previous method would only update the type after the check was being performed
1 parent 614da61 commit f83708c

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/main/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLRequestSerializer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static String toHttpJsonBody(GraphQLRequests graphQLRequests) {
3030
if (graphQLRequests.getRequests().isEmpty()) {
3131
throw new IllegalArgumentException("At least one GraphQL request should be supplied");
3232
}
33-
GraphQLOperation operation = GraphQLOperation.QUERY;
33+
GraphQLOperation operation = graphQLRequests.getRequests().get(0).getRequest().getOperationType();
3434
StringBuilder queryBuilder = new StringBuilder();
3535
for (GraphQLRequest request : graphQLRequests.getRequests()) {
3636
if (request == null || request.getRequest() == null) {
@@ -40,7 +40,6 @@ public static String toHttpJsonBody(GraphQLRequests graphQLRequests) {
4040
throw new IllegalArgumentException("Only operations of the same type (query/mutation/subscription) can be executed at once");
4141
}
4242
queryBuilder.append(buildQuery(request)).append(" ");
43-
operation = request.getRequest().getOperationType();
4443
}
4544
return jsonQuery(operationWrapper(queryBuilder.toString(), operation));
4645
}

0 commit comments

Comments
 (0)