|
2 | 2 |
|
3 | 3 | import graphql.GraphQL; |
4 | 4 | import graphql.schema.GraphQLSchema; |
5 | | -import org.springframework.beans.factory.annotation.Autowired; |
| 5 | +import org.springframework.boot.autoconfigure.AutoConfigureAfter; |
6 | 6 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
7 | 7 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
8 | 8 | import org.springframework.boot.context.properties.EnableConfigurationProperties; |
9 | 9 | import org.springframework.context.annotation.Bean; |
10 | 10 | import org.springframework.context.annotation.Configuration; |
11 | 11 | import org.springframework.context.annotation.PropertySource; |
12 | 12 | import org.springframework.context.annotation.PropertySources; |
13 | | -import org.springframework.util.CollectionUtils; |
14 | 13 |
|
15 | | -import java.util.ArrayList; |
16 | 14 | import java.util.List; |
17 | 15 |
|
18 | 16 | @Configuration |
|
22 | 20 | @PropertySource("classpath:com/introproventures/graphql/jpa/query/boot/autoconfigure/default.properties"), |
23 | 21 | @PropertySource(value = "classpath:graphql-jpa-autoconfigure.properties", ignoreResourceNotFound = true) |
24 | 22 | }) |
| 23 | +@AutoConfigureAfter(GraphQLSchemaBuilderAutoConfiguration.class) |
25 | 24 | public class GraphQLSchemaAutoConfiguration { |
26 | 25 |
|
27 | | - private final List<GraphQLSchemaConfigurer> graphQLSchemaConfigurers = new ArrayList<>(); |
28 | | - |
29 | | - @Autowired(required = true) |
30 | | - public void setGraphQLSchemaConfigurers(List<GraphQLSchemaConfigurer> configurers) { |
31 | | - if (!CollectionUtils.isEmpty(configurers)) { |
32 | | - graphQLSchemaConfigurers.addAll(configurers); |
33 | | - } |
| 26 | + @Bean |
| 27 | + @ConditionalOnMissingBean |
| 28 | + public GraphQLShemaRegistration graphQLShemaRegistration() { |
| 29 | + return new GraphQLShemaRegistrationImpl(); |
34 | 30 | } |
35 | | - |
| 31 | + |
36 | 32 | @Bean |
37 | 33 | @ConditionalOnMissingBean(GraphQLSchema.class) |
38 | | - public GraphQLSchemaFactoryBean graphQLSchemaFactoryBean(GraphQLJpaQueryProperties properties) { |
39 | | - GraphQLShemaRegistrationImpl graphQLShemaRegistration = new GraphQLShemaRegistrationImpl(); |
40 | | - |
| 34 | + public GraphQLSchemaFactoryBean graphQLSchemaFactoryBean(GraphQLJpaQueryProperties properties, |
| 35 | + GraphQLShemaRegistration graphQLShemaRegistration, |
| 36 | + List<GraphQLSchemaConfigurer> graphQLSchemaConfigurers) { |
41 | 37 | for (GraphQLSchemaConfigurer configurer : graphQLSchemaConfigurers) { |
42 | 38 | configurer.configure(graphQLShemaRegistration); |
43 | 39 | } |
44 | | - |
| 40 | + |
45 | 41 | return new GraphQLSchemaFactoryBean(graphQLShemaRegistration.getManagedGraphQLSchemas()) |
46 | 42 | .setQueryName(properties.getName()) |
47 | 43 | .setQueryDescription(properties.getDescription()); |
48 | | - |
49 | | - |
| 44 | + |
| 45 | + |
50 | 46 | }; |
51 | | - |
52 | | - |
| 47 | + |
53 | 48 | } |
0 commit comments