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

Commit 4b664e9

Browse files
committed
Reformat code
1 parent f6d6aaa commit 4b664e9

File tree

167 files changed

+172964
-8027
lines changed

Some content is hidden

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

167 files changed

+172964
-8027
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

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

11-
[Reach out to us on Discussions](https://github.com/graphql-java-kickstart/graphql-spring-boot/discussions) 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 -->

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
}

altair-spring-boot-autoconfigure/src/main/resources/altair.html

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,54 @@
22
<html>
33

44
<head>
5-
<meta charset="utf-8">
6-
<title>${pageTitle}</title>
7-
<base href="${altairBaseUrl}">
8-
<meta name="viewport" content="width=device-width, initial-scale=1">
9-
<link rel="icon" type="image/x-icon" href="${pageFavicon}">
10-
<link rel="stylesheet" href="${altairCssUrl}"/>
5+
<meta charset="utf-8">
6+
<title>${pageTitle}</title>
7+
<base href="${altairBaseUrl}">
8+
<meta content="width=device-width, initial-scale=1" name="viewport">
9+
<link href="${pageFavicon}" rel="icon" type="image/x-icon">
10+
<link href="${altairCssUrl}" rel="stylesheet" />
1111

1212
</head>
1313

1414
<body>
1515
<script>
16-
var properties = JSON.parse(`${props}`);
16+
var properties = JSON.parse(`${props}`)
1717

18-
window.__ALTAIR_ENDPOINT_URL__ = `${graphqlEndpoint}`;
19-
window.__ALTAIR_SUBSCRIPTIONS_ENDPOINT__ = `${subscriptionsEndpoint}`;
20-
window.__ALTAIR_INITIAL_QUERY__ = `${properties.defaultQuery}`;
21-
window.__ALTAIR_INITIAL_VARIABLES__ = `${properties.variables}`;
22-
window.__ALTAIR_INITIAL_HEADERS__ = JSON.parse(`${headers}`);
18+
window.__ALTAIR_ENDPOINT_URL__ = `${graphqlEndpoint}`
19+
window.__ALTAIR_SUBSCRIPTIONS_ENDPOINT__ = `${subscriptionsEndpoint}`
20+
window.__ALTAIR_INITIAL_QUERY__ = `${properties.defaultQuery}`
21+
window.__ALTAIR_INITIAL_VARIABLES__ = `${properties.variables}`
22+
window.__ALTAIR_INITIAL_HEADERS__ = JSON.parse(`${headers}`)
2323

2424
</script>
2525
<app-root>
26-
<style>
27-
.loading-screen {
28-
/*Prevents the loading screen from showing until CSS is downloaded*/
29-
display: none;
30-
}
31-
</style>
32-
<div class="loading-screen styled">
33-
<div class="loading-screen-inner">
34-
<div class="loading-screen-logo-container">
35-
<img src="${altairLogoUrl}" alt="Altair">
36-
</div>
37-
<div class="loading-screen-loading-indicator">
38-
<span class="loading-indicator-dot"></span>
39-
<span class="loading-indicator-dot"></span>
40-
<span class="loading-indicator-dot"></span>
41-
</div>
42-
</div>
26+
<style>
27+
.loading-screen {
28+
/*Prevents the loading screen from showing until CSS is downloaded*/
29+
display: none;
30+
}
31+
</style>
32+
<div class="loading-screen styled">
33+
<div class="loading-screen-inner">
34+
<div class="loading-screen-logo-container">
35+
<img alt="Altair" src="${altairLogoUrl}">
36+
</div>
37+
<div class="loading-screen-loading-indicator">
38+
<span class="loading-indicator-dot"></span>
39+
<span class="loading-indicator-dot"></span>
40+
<span class="loading-indicator-dot"></span>
41+
</div>
4342
</div>
43+
</div>
4444
</app-root>
4545
<script>
46-
document.addEventListener('DOMContentLoaded', () => {
47-
AltairGraphQL.init();
48-
});
46+
document.addEventListener('DOMContentLoaded', () => {
47+
AltairGraphQL.init()
48+
})
4949
</script>
50-
<script rel="preload" as="script" type="text/javascript" src="${altairRuntimeJsUrl}"></script>
51-
<script rel="preload" as="script" type="text/javascript" src="${altairPolyfillsJsUrl}"></script>
52-
<script rel="preload" as="script" type="text/javascript" src="${altairMainJsUrl}"></script>
50+
<script as="script" rel="preload" src="${altairRuntimeJsUrl}" type="text/javascript"></script>
51+
<script as="script" rel="preload" src="${altairPolyfillsJsUrl}" type="text/javascript"></script>
52+
<script as="script" rel="preload" src="${altairMainJsUrl}" type="text/javascript"></script>
5353
</body>
5454

5555
</html>

altair-spring-boot-autoconfigure/src/main/resources/static/vendor/altair/assets/i18n/cn.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"SAVE_BUTTON": "保存",
1515
"DONE_BUTTON": "完成",
1616
"ADD_NEW_WINDOW_TEXT": "+ 新建窗口",
17-
1817
"DOCS_GO_BACK_TEXT": "返回",
1918
"DOCS_SEARCH_INPUT_PLACEHOLDER_TEXT": "搜索文档...",
2019
"DOCS_ARGUMENTS_TEXT": "Arguments",
@@ -28,37 +27,28 @@
2827
"DOCS_ADD_FRAGMENT_TEXT": "添加片段",
2928
"DOCS_UNION_TEXT": "Union",
3029
"DOCS_SUBTYPES_TEXT": "Subtypes",
31-
3230
"QUERY_RESULT_NO_RESULT_TEXT": "Ezio my friend, how may I be of service?",
3331
"QUERY_RESULT_STATUS_TEXT": "状态",
3432
"QUERY_RESULT_STATUS_CODE_TEXT": "状态码",
3533
"QUERY_RESULT_TIME_SPENT_TEXT": "耗时",
3634
"QUERY_RESULT_DOWNLOAD_RESULT_BUTTON": "下载",
37-
3835
"VARIABLES_TEXT": "变量",
3936
"SET_VARIABLES_DIALOG_SUBTEXT": "添加、编辑或移除请求中的变量",
40-
4137
"HEADERS_TEXT": "Headers",
4238
"SET_HEADERS_DIALOG_SUBTEXT": "添加、编辑或移除请求中的Headers",
4339
"ADD_HEADER_TEXT": "添加Header",
44-
4540
"SUBSCRIPTION_URL_TEXT": "订阅地址",
4641
"SET_SUBSCRIPTION_URL_TEXT": "输入您服务的订阅地址",
47-
4842
"HISTORY_TEXT": "历史",
4943
"HISTORY_SUB_TEXT": "你可以选择一个历史记录还原",
50-
5144
"SETTINGS_TEXT": "设置",
5245
"SETTINGS_SUB_TEXT": "你可以调整如下设置",
5346
"SETTINGS_THEME_TEXT": "主题",
5447
"SETTINGS_LANGUAGE_TEXT": "语言",
55-
5648
"VIEW_ON_GITHUB_TEXT": "在GitHub上打开",
57-
5849
"EDIT_WINDOW_TEXT": "编辑",
5950
"CLOSE_WINDOW_TEXT": "关闭",
6051
"DUPLICATE_WINDOW_TEXT": "复制",
61-
6252
"IMPORT_WINDOW_TEXT": "导入窗口",
6353
"EXPORT_WINDOW_TEXT": "导出窗口"
6454
}

0 commit comments

Comments
 (0)