Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Commit 2d34029

Browse files
authored
Merge pull request #492 from graphql-java-kickstart/feature/servlet-11
Feature/servlet 11
2 parents d974748 + aa9552e commit 2d34029

File tree

170 files changed

+173013
-8072
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+173013
-8072
lines changed

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# GraphQL and Graph*i*QL Spring Framework Boot Starters
22

3-
[![GitHub CI Workflow](https://github.com/graphql-java-kickstart/graphql-spring-boot/workflows/ci/badge.svg)](https://github.com/graphql-java-kickstart/graphql-spring-boot/actions?query=workflow%3ACI+branch%3Amaster)
43
[![Maven Central](https://img.shields.io/maven-central/v/com.graphql-java-kickstart/graphql-spring-boot-starter.svg)](https://maven-badges.herokuapp.com/maven-central/com.graphql-java-kickstart/graphql-spring-boot-starter)
5-
[![Chat on Spectrum](https://img.shields.io/badge/spectrum-join%20the%20community-%23800080)](https://spectrum.chat/graphql-java-kick)
4+
[![GitHub CI Workflow](https://github.com/graphql-java-kickstart/graphql-spring-boot/workflows/ci/badge.svg)](https://github.com/graphql-java-kickstart/graphql-spring-boot/actions?query=workflow%3ACI+branch%3Amaster)
5+
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=graphql-java-kickstart_graphql-spring-boot&metric=alert_status)](https://sonarcloud.io/dashboard?id=graphql-java-kickstart_graphql-spring-boot)
66

77
#### We are looking for contributors!
88

99
Are you interested in improving our documentation, working on the codebase, reviewing PRs?
1010

11-
[Reach out to us on Spectrum](https://spectrum.chat/graphql-java-kick) and join the team!
11+
[Reach out to us on Discussions](https://github.com/graphql-java-kickstart/graphql-spring-boot/discussions)
12+
and join the team!
1213

1314

1415
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
@@ -107,19 +108,19 @@ repositories {
107108
}
108109
109110
dependencies {
110-
implementation 'com.graphql-java-kickstart:graphql-spring-boot-starter:8.0.0'
111+
implementation 'com.graphql-java-kickstart:graphql-spring-boot-starter:8.1.0'
111112
112113
// to embed Altair tool
113-
runtimeOnly 'com.graphql-java-kickstart:altair-spring-boot-starter:8.0.0'
114+
runtimeOnly 'com.graphql-java-kickstart:altair-spring-boot-starter:8.1.0'
114115
115116
// to embed GraphiQL tool
116-
runtimeOnly 'com.graphql-java-kickstart:graphiql-spring-boot-starter:8.0.0'
117+
runtimeOnly 'com.graphql-java-kickstart:graphiql-spring-boot-starter:8.1.0'
117118
118119
// to embed Voyager tool
119-
runtimeOnly 'com.graphql-java-kickstart:voyager-spring-boot-starter:8.0.0'
120+
runtimeOnly 'com.graphql-java-kickstart:voyager-spring-boot-starter:8.1.0'
120121
121122
// testing facilities
122-
testImplementation 'com.graphql-java-kickstart:graphql-spring-boot-starter-test:8.0.0'
123+
testImplementation 'com.graphql-java-kickstart:graphql-spring-boot-starter-test:8.1.0'
123124
}
124125
```
125126

@@ -129,38 +130,38 @@ Maven:
129130
<dependency>
130131
<groupId>com.graphql-java-kickstart</groupId>
131132
<artifactId>graphql-spring-boot-starter</artifactId>
132-
<version>8.0.0</version>
133+
<version>8.1.0</version>
133134
</dependency>
134135

135136
<!-- to embed Altair tool -->
136137
<dependency>
137138
<groupId>com.graphql-java-kickstart</groupId>
138139
<artifactId>altair-spring-boot-starter</artifactId>
139-
<version>8.0.0</version>
140+
<version>8.1.0</version>
140141
<scope>runtime</scope>
141142
</dependency>
142143

143144
<!-- to embed GraphiQL tool -->
144145
<dependency>
145146
<groupId>com.graphql-java-kickstart</groupId>
146147
<artifactId>graphiql-spring-boot-starter</artifactId>
147-
<version>8.0.0</version>
148+
<version>8.1.0</version>
148149
<scope>runtime</scope>
149150
</dependency>
150151

151152
<!-- to embed Voyager tool -->
152153
<dependency>
153154
<groupId>com.graphql-java-kickstart</groupId>
154155
<artifactId>voyager-spring-boot-starter</artifactId>
155-
<version>8.0.0</version>
156+
<version>8.1.0</version>
156157
<scope>runtime</scope>
157158
</dependency>
158159

159160
<!-- testing facilities -->
160161
<dependency>
161162
<groupId>com.graphql-java-kickstart</groupId>
162163
<artifactId>graphql-spring-boot-starter-test</artifactId>
163-
<version>8.0.0</version>
164+
<version>8.1.0</version>
164165
<scope>test</scope>
165166
</dependency>
166167

altair-spring-boot-autoconfigure/src/main/java/graphql/kickstart/altair/boot/AltairAutoConfiguration.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
@ConditionalOnClass(DispatcherServlet.class)
1818
public class AltairAutoConfiguration {
1919

20-
@Bean
21-
@ConditionalOnProperty(value = "altair.enabled", havingValue = "true", matchIfMissing = true)
22-
AltairController altairController() {
23-
return new AltairController();
24-
}
20+
@Bean
21+
@ConditionalOnProperty(value = "altair.enabled", havingValue = "true", matchIfMissing = true)
22+
AltairController altairController() {
23+
return new AltairController();
24+
}
2525

2626
}

altair-spring-boot-autoconfigure/src/main/java/graphql/kickstart/altair/boot/AltairProperties.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,20 @@ public class AltairProperties {
1616

1717
@Data
1818
static class Endpoint {
19+
1920
private String graphql = "/graphql";
2021
private String subscriptions = "/subscriptions";
2122
}
2223

2324
@Data
2425
static class Static {
26+
2527
private String basePath = "";
2628
}
2729

2830
@Data
2931
static class Cdn {
32+
3033
private boolean enabled = false;
3134
private String version = "2.4.11";
3235
}

altair-spring-boot-autoconfigure/src/main/java/graphql/kickstart/altair/boot/PropertyGroupReader.java

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,66 @@
11
package graphql.kickstart.altair.boot;
22

3+
import java.util.Arrays;
4+
import java.util.Iterator;
5+
import java.util.Objects;
6+
import java.util.Optional;
7+
import java.util.Properties;
8+
import java.util.stream.Stream;
9+
import java.util.stream.StreamSupport;
310
import org.springframework.core.env.ConfigurableEnvironment;
411
import org.springframework.core.env.EnumerablePropertySource;
512
import org.springframework.core.env.Environment;
613
import org.springframework.core.env.PropertySource;
714

8-
import java.util.*;
9-
import java.util.stream.Stream;
10-
import java.util.stream.StreamSupport;
11-
1215
class PropertyGroupReader {
1316

14-
private Environment environment;
15-
private String prefix;
16-
private Properties props;
17+
private Environment environment;
18+
private String prefix;
19+
private Properties props;
1720

18-
PropertyGroupReader(Environment environment, String prefix) {
19-
this.environment = Objects.requireNonNull(environment);
20-
this.prefix = Optional.ofNullable(prefix).orElse("");
21-
}
21+
PropertyGroupReader(Environment environment, String prefix) {
22+
this.environment = Objects.requireNonNull(environment);
23+
this.prefix = Optional.ofNullable(prefix).orElse("");
24+
}
2225

23-
Properties load() {
24-
if (props == null) {
25-
props = new Properties();
26-
loadProps();
27-
}
28-
return props;
26+
Properties load() {
27+
if (props == null) {
28+
props = new Properties();
29+
loadProps();
2930
}
31+
return props;
32+
}
3033

31-
private void loadProps() {
32-
streamOfPropertySources().forEach(propertySource ->
33-
Arrays.stream(propertySource.getPropertyNames())
34-
.filter(this::isWanted)
35-
.forEach(key -> add(propertySource, key)));
36-
}
34+
private void loadProps() {
35+
streamOfPropertySources().forEach(propertySource ->
36+
Arrays.stream(propertySource.getPropertyNames())
37+
.filter(this::isWanted)
38+
.forEach(key -> add(propertySource, key)));
39+
}
3740

38-
private Stream<EnumerablePropertySource> streamOfPropertySources() {
39-
if (environment instanceof ConfigurableEnvironment) {
40-
Iterator<PropertySource<?>> iterator = ((ConfigurableEnvironment) environment).getPropertySources().iterator();
41-
Iterable<PropertySource<?>> iterable = () -> iterator;
42-
return StreamSupport.stream(iterable.spliterator(), false)
43-
.filter(EnumerablePropertySource.class::isInstance)
44-
.map(EnumerablePropertySource.class::cast);
45-
}
46-
return Stream.empty();
41+
private Stream<EnumerablePropertySource> streamOfPropertySources() {
42+
if (environment instanceof ConfigurableEnvironment) {
43+
Iterator<PropertySource<?>> iterator = ((ConfigurableEnvironment) environment)
44+
.getPropertySources().iterator();
45+
Iterable<PropertySource<?>> iterable = () -> iterator;
46+
return StreamSupport.stream(iterable.spliterator(), false)
47+
.filter(EnumerablePropertySource.class::isInstance)
48+
.map(EnumerablePropertySource.class::cast);
4749
}
50+
return Stream.empty();
51+
}
4852

49-
private String withoutPrefix(String key) {
50-
return key.replace(prefix, "");
51-
}
53+
private String withoutPrefix(String key) {
54+
return key.replace(prefix, "");
55+
}
5256

53-
private boolean isWanted(String key) {
54-
return key.startsWith(prefix);
55-
}
56-
57-
private Object add(EnumerablePropertySource propertySource, String key) {
58-
return props.put(withoutPrefix(key), propertySource.getProperty(key));
59-
}
57+
private boolean isWanted(String key) {
58+
return key.startsWith(prefix);
59+
}
6060

61+
private Object add(EnumerablePropertySource propertySource, String key) {
62+
return props.put(withoutPrefix(key), propertySource.getProperty(key));
63+
}
6164

6265

6366
}
Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,53 @@
11
package graphql.kickstart.altair.boot;
22

33
import com.fasterxml.jackson.databind.ObjectMapper;
4-
import org.springframework.core.env.Environment;
5-
import org.springframework.core.io.ClassPathResource;
6-
import org.springframework.core.io.Resource;
7-
import org.springframework.util.StreamUtils;
8-
94
import java.io.IOException;
105
import java.io.InputStream;
116
import java.nio.charset.StandardCharsets;
127
import java.util.Optional;
138
import java.util.Properties;
9+
import org.springframework.core.env.Environment;
10+
import org.springframework.core.io.ClassPathResource;
11+
import org.springframework.core.io.Resource;
12+
import org.springframework.util.StreamUtils;
1413

1514
class PropsLoader {
1615

17-
private static final String ALTAIR_PROPS_PREFIX = "altair.props.";
18-
private static final String ALTAIR_PROPS_RESOURCES_PREFIX = ALTAIR_PROPS_PREFIX + "resources.";
19-
private static final String ALTAIR_PROPS_VALUES_PREFIX = ALTAIR_PROPS_PREFIX + "values.";
20-
21-
private Environment environment;
22-
23-
PropsLoader(Environment environment) {
24-
this.environment = environment;
25-
}
26-
27-
String load() throws IOException {
28-
PropertyGroupReader reader = new PropertyGroupReader(environment, ALTAIR_PROPS_VALUES_PREFIX);
29-
Properties props = reader.load();
30-
31-
ObjectMapper objectMapper = new ObjectMapper();
32-
loadPropFromResource("defaultQuery").ifPresent(it -> props.put("defaultQuery", it));
33-
loadPropFromResource("query").ifPresent(it -> props.put("query", it));
34-
loadPropFromResource("variables").ifPresent(it -> props.put("variables", it));
35-
return objectMapper.writeValueAsString(props);
36-
}
37-
38-
private Optional<String> loadPropFromResource(String prop) throws IOException {
39-
String property = ALTAIR_PROPS_RESOURCES_PREFIX + prop;
40-
if (environment.containsProperty(property)) {
41-
String location = environment.getProperty(property);
42-
Resource resource = new ClassPathResource(location);
43-
return Optional.of(loadResource(resource));
44-
}
45-
return Optional.empty();
16+
private static final String ALTAIR_PROPS_PREFIX = "altair.props.";
17+
private static final String ALTAIR_PROPS_RESOURCES_PREFIX = ALTAIR_PROPS_PREFIX + "resources.";
18+
private static final String ALTAIR_PROPS_VALUES_PREFIX = ALTAIR_PROPS_PREFIX + "values.";
19+
20+
private Environment environment;
21+
22+
PropsLoader(Environment environment) {
23+
this.environment = environment;
24+
}
25+
26+
String load() throws IOException {
27+
PropertyGroupReader reader = new PropertyGroupReader(environment, ALTAIR_PROPS_VALUES_PREFIX);
28+
Properties props = reader.load();
29+
30+
ObjectMapper objectMapper = new ObjectMapper();
31+
loadPropFromResource("defaultQuery").ifPresent(it -> props.put("defaultQuery", it));
32+
loadPropFromResource("query").ifPresent(it -> props.put("query", it));
33+
loadPropFromResource("variables").ifPresent(it -> props.put("variables", it));
34+
return objectMapper.writeValueAsString(props);
35+
}
36+
37+
private Optional<String> loadPropFromResource(String prop) throws IOException {
38+
String property = ALTAIR_PROPS_RESOURCES_PREFIX + prop;
39+
if (environment.containsProperty(property)) {
40+
String location = environment.getProperty(property);
41+
Resource resource = new ClassPathResource(location);
42+
return Optional.of(loadResource(resource));
4643
}
44+
return Optional.empty();
45+
}
4746

48-
private String loadResource(Resource resource) throws IOException {
49-
try (InputStream inputStream = resource.getInputStream()) {
50-
return StreamUtils.copyToString(inputStream, StandardCharsets.UTF_8);
51-
}
47+
private String loadResource(Resource resource) throws IOException {
48+
try (InputStream inputStream = resource.getInputStream()) {
49+
return StreamUtils.copyToString(inputStream, StandardCharsets.UTF_8);
5250
}
51+
}
5352

5453
}

0 commit comments

Comments
 (0)