Expose ExecutionInput in WebOutput

WebOutput now exposes the ExecutionInput prepared for the request and
no longer provides access to the WebInput which is already available
to a WebInterceptor.

Closes gh-229
This commit is contained in:
rstoyanchev
2022-01-07 21:27:08 +00:00
parent c84f342daf
commit 22985efe6a
8 changed files with 47 additions and 40 deletions

View File

@@ -24,6 +24,7 @@ import java.util.concurrent.atomic.AtomicReference;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import graphql.ExecutionInput;
import graphql.ExecutionResult;
import graphql.ExecutionResultImpl;
import graphql.GraphQLError;
@@ -352,9 +353,10 @@ public class GraphQlTesterTests {
if (!CollectionUtils.isEmpty(errors)) {
builder.addErrors(errors);
}
RequestInput input = new RequestInput("{}", null, null, null, "1");
ExecutionInput executionInput = ExecutionInput.newExecutionInput("{}").build();
ExecutionResult result = builder.build();
given(this.service.execute(this.inputCaptor.capture())).willReturn(Mono.just(new RequestOutput(input, result)));
given(this.service.execute(this.inputCaptor.capture()))
.willReturn(Mono.just(new RequestOutput(executionInput, result)));
}
}

View File

@@ -26,6 +26,7 @@ import java.util.stream.Stream;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import graphql.ExecutionInput;
import graphql.ExecutionResult;
import graphql.ExecutionResultImpl;
import graphql.GraphQLError;
@@ -38,6 +39,7 @@ import org.junit.jupiter.params.provider.MethodSource;
import org.mockito.ArgumentCaptor;
import reactor.core.publisher.Mono;
import org.springframework.graphql.RequestOutput;
import org.springframework.graphql.web.WebGraphQlHandler;
import org.springframework.graphql.web.WebInput;
import org.springframework.graphql.web.WebOutput;
@@ -271,8 +273,9 @@ public class WebGraphQlTesterTests {
if (!CollectionUtils.isEmpty(errors)) {
builder.addErrors(errors);
}
ExecutionInput executionInput = ExecutionInput.newExecutionInput("{}").build();
ExecutionResult result = builder.build();
WebOutput output = new WebOutput(mock(WebInput.class), result);
WebOutput output = new WebOutput(new RequestOutput(executionInput, result));
given(this.handler.handleRequest(this.bodyCaptor.capture())).willReturn(Mono.just(output));
}