Skip to content

Commit 9987fee

Browse files
committed
Static factory method to create GraphQLWebClient fixes #2
1 parent f3225f6 commit 9987fee

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

graphql-webclient/src/main/java/graphql/kickstart/spring/webclient/boot/GraphQLWebClient.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
package graphql.kickstart.spring.webclient.boot;
22

3+
import com.fasterxml.jackson.databind.ObjectMapper;
34
import java.util.Map;
5+
import org.springframework.web.reactive.function.client.WebClient;
46
import reactor.core.publisher.Flux;
57
import reactor.core.publisher.Mono;
68

79
public interface GraphQLWebClient {
810

11+
static GraphQLWebClient newInstance(WebClient webClient, ObjectMapper objectMapper) {
12+
return new GraphQLWebClientImpl(webClient, objectMapper);
13+
}
14+
915
<T> Mono<T> post(String resource, Class<T> returnType);
1016

1117
<T> Mono<T> post(String resource, Map<String, Object> variables, Class<T> returnType);

graphql-webclient/src/test/java/graphql/kickstart/spring/webclient/boot/GraphQLWebClientTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void beforeEach() {
3737
WebClient webClient = WebClient.builder()
3838
.baseUrl("http://localhost:" + randomServerPort + "/graphql")
3939
.build();
40-
graphqlClient = new GraphQLWebClientImpl(webClient, objectMapper);
40+
graphqlClient = GraphQLWebClient.newInstance(webClient, objectMapper);
4141
}
4242

4343
@Test

0 commit comments

Comments
 (0)