|
1 | 1 | package graphql.kickstart.spring.webclient.boot; |
2 | 2 |
|
| 3 | +import com.fasterxml.jackson.databind.ObjectMapper; |
3 | 4 | import lombok.extern.slf4j.Slf4j; |
| 5 | +import org.springframework.boot.autoconfigure.AutoConfigureAfter; |
4 | 6 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
| 7 | +import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; |
5 | 8 | import org.springframework.context.annotation.Bean; |
6 | 9 | import org.springframework.context.annotation.ComponentScan; |
7 | 10 | import org.springframework.context.annotation.Configuration; |
8 | 11 | import org.springframework.web.reactive.function.client.WebClient; |
9 | 12 |
|
10 | 13 | @Slf4j |
11 | 14 | @Configuration |
| 15 | +@AutoConfigureAfter(JacksonAutoConfiguration.class) |
12 | 16 | @ComponentScan(basePackageClasses = GraphQLWebClientImpl.class) |
13 | 17 | public class GraphQLWebClientAutoConfiguration { |
14 | 18 |
|
15 | 19 | @Bean |
16 | 20 | @ConditionalOnMissingBean |
17 | 21 | public WebClient webClient() { |
18 | | - return null; |
| 22 | + return WebClient.builder().build(); |
19 | 23 | } |
20 | 24 |
|
21 | 25 | @Bean |
22 | 26 | @ConditionalOnMissingBean |
23 | | - public GraphQLWebClient graphQLWebClient(WebClient webClient) { |
24 | | - return new GraphQLWebClientImpl(webClient); |
| 27 | + public ObjectMapper objectMapper() { |
| 28 | + return new ObjectMapper(); |
| 29 | + } |
| 30 | + |
| 31 | + @Bean |
| 32 | + @ConditionalOnMissingBean |
| 33 | + public GraphQLWebClient graphQLWebClient(WebClient webClient, ObjectMapper objectMapper) { |
| 34 | + return new GraphQLWebClientImpl(webClient, objectMapper); |
25 | 35 | } |
26 | 36 |
|
27 | 37 | } |
0 commit comments