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

Commit f3410c2

Browse files
committed
Adding properties to configure all of the Voyager configurations (displayOptions, hideDocs, hideSettings)
1 parent 32a84bc commit f3410c2

File tree

2 files changed

+53
-12
lines changed

2 files changed

+53
-12
lines changed

voyager-spring-boot-autoconfigure/src/main/java/graphql/kickstart/voyager/boot/VoyagerIndexHtmlTemplate.java

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,39 @@ public class VoyagerIndexHtmlTemplate {
2727
@Value("${voyager.pageTitle:Voyager}")
2828
private String pageTitle;
2929

30-
@Value("${voyager.static.basePath:/}")
31-
private String staticBasePath;
30+
@Value("${voyager.basePath:/}")
31+
private String basePath;
3232

3333
@Value("${voyager.cdn.enabled:false}")
3434
private boolean voyagerCdnEnabled;
3535

3636
@Value("${voyager.cdn.version:1.0.0-rc.31}")
3737
private String voyagerCdnVersion;
3838

39+
@Value("${voyager.displayOptions.skipRelay:true}")
40+
private boolean voyagerDisplayOptionsSkipRelay;
41+
42+
@Value("${voyager.displayOptions.skipDeprecated:true}")
43+
private boolean voyagerDisplayOptionsSkipDeprecated;
44+
45+
@Value("${voyager.displayOptions.rootType:Query}")
46+
private String voyagerDisplayOptionsRootType;
47+
48+
@Value("${voyager.displayOptions.sortByAlphabet:false}")
49+
private boolean voyagerDisplayOptionsSortByAlphabet;
50+
51+
@Value("${voyager.displayOptions.showLeafFields:true}")
52+
private boolean voyagerDisplayOptionsShowLeafFields;
53+
54+
@Value("${voyager.displayOptions.hideRoot:false}")
55+
private boolean voyagerDisplayOptionsHideRoot;
56+
57+
@Value("${voyager.hideDocs:false}")
58+
private boolean voyagerHideDocs;
59+
60+
@Value("${voyager.hideSettings:false}")
61+
private boolean voyagerHideSettings;
62+
3963
public String fillIndexTemplate(String contextPath, Map<String, String> params)
4064
throws IOException {
4165
String template = StreamUtils
@@ -45,22 +69,32 @@ public String fillIndexTemplate(String contextPath, Map<String, String> params)
4569
replacements.put("graphqlEndpoint", constructGraphQlEndpoint(contextPath, params));
4670
replacements.put("pageTitle", pageTitle);
4771
replacements
48-
.put("pageFavicon", getResourceUrl(staticBasePath, "favicon.ico", FAVICON_APIS_GURU));
49-
replacements.put("es6PromiseJsUrl", getResourceUrl(staticBasePath, "es6-promise.auto.min.js",
72+
.put("pageFavicon", getResourceUrl(basePath, "favicon.ico", FAVICON_APIS_GURU));
73+
replacements.put("es6PromiseJsUrl", getResourceUrl(basePath, "es6-promise.auto.min.js",
5074
joinCdnjsPath("es6-promise", "4.1.1", "es6-promise.auto.min.js")));
51-
replacements.put("fetchJsUrl", getResourceUrl(staticBasePath, "fetch.min.js",
75+
replacements.put("fetchJsUrl", getResourceUrl(basePath, "fetch.min.js",
5276
joinCdnjsPath("fetch", "2.0.4", "fetch.min.js")));
53-
replacements.put("reactJsUrl", getResourceUrl(staticBasePath, "react.min.js",
77+
replacements.put("reactJsUrl", getResourceUrl(basePath, "react.min.js",
5478
joinCdnjsPath("react", "16.8.3", "umd/react.production.min.js")));
55-
replacements.put("reactDomJsUrl", getResourceUrl(staticBasePath, "react-dom.min.js",
79+
replacements.put("reactDomJsUrl", getResourceUrl(basePath, "react-dom.min.js",
5680
joinCdnjsPath("react-dom", "16.8.3", "umd/react-dom.production.min.js")));
57-
replacements.put("voyagerCssUrl", getResourceUrl(staticBasePath, "voyager.css",
81+
replacements.put("voyagerCssUrl", getResourceUrl(basePath, "voyager.css",
5882
joinJsDelivrPath(voyagerCdnVersion, "dist/voyager.css")));
59-
replacements.put("voyagerJsUrl", getResourceUrl(staticBasePath, "voyager.min.js",
83+
replacements.put("voyagerJsUrl", getResourceUrl(basePath, "voyager.min.js",
6084
joinJsDelivrPath(voyagerCdnVersion, "dist/voyager.min.js")));
61-
replacements.put("voyagerWorkerJsUrl", getResourceUrl(staticBasePath, "voyager.worker.js",
85+
replacements.put("voyagerWorkerJsUrl", getResourceUrl(basePath, "voyager.worker.js",
6286
joinJsDelivrPath(voyagerCdnVersion, "dist/voyager.worker.min.js")));
6387
replacements.put("contextPath", contextPath);
88+
replacements.put("voyagerDisplayOptionsSkipRelay", Boolean.toString(voyagerDisplayOptionsSkipRelay));
89+
replacements.put("voyagerDisplayOptionsSkipDeprecated", Boolean.toString(voyagerDisplayOptionsSkipDeprecated));
90+
replacements.put("voyagerDisplayOptionsRootType", voyagerDisplayOptionsRootType);
91+
replacements.put("voyagerDisplayOptionsSortByAlphabet", Boolean.toString(voyagerDisplayOptionsSortByAlphabet));
92+
replacements.put("voyagerDisplayOptionsShowLeafFields", Boolean.toString(voyagerDisplayOptionsShowLeafFields));
93+
replacements.put("voyagerDisplayOptionsHideRoot", Boolean.toString(voyagerDisplayOptionsHideRoot));
94+
replacements.put("voyagerHideDocs", Boolean.toString(voyagerHideDocs));
95+
replacements.put("voyagerHideSettings", Boolean.toString(voyagerHideSettings));
96+
97+
6498

6599
return StringSubstitutor.replace(template, replacements);
66100
}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,15 @@ <h1> Transmitting... </h1>
7373
GraphQLVoyager.init(document.getElementById('voyager'), {
7474
introspection: introspectionProvider,
7575
displayOptions: {
76-
sortByAlphabet: true,
77-
}
76+
skipRelay: ${voyagerDisplayOptionsSkipRelay},
77+
skipDeprecated: ${voyagerDisplayOptionsSkipDeprecated},
78+
rootType: '${voyagerDisplayOptionsRootType}',
79+
sortByAlphabet: ${voyagerDisplayOptionsSortByAlphabet},
80+
showLeafFields: ${voyagerDisplayOptionsShowLeafFields},
81+
hideRoot: ${voyagerDisplayOptionsHideRoot},
82+
},
83+
hideDocs: ${voyagerHideDocs},
84+
hideSettings: ${voyagerHideSettings},
7885
})
7986
</script>
8087
</body>

0 commit comments

Comments
 (0)