Skip to content

Commit 891e69e

Browse files
deploy: a4ff0b9
1 parent 983eeaf commit 891e69e

79 files changed

Lines changed: 1345 additions & 231 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
6+
<title>WebTau: Customized Graphql Urls</title>
7+
<link rel="stylesheet" type="text/css" href="/webtau/static/css/katex.min.css">
8+
<link rel="stylesheet" type="text/css" href="/webtau/static/main.css">
9+
<link rel="stylesheet" type="text/css" href="/webtau/logo.css">
10+
<link rel="stylesheet" type="text/css" href="/webtau/static/css/global-overrides.css">
11+
</head>
12+
<link rel="shortcut icon" href="/webtau/favicon.png"type="image/ico"/>
13+
<body class="theme-znai-dark">
14+
<script>(function() {
15+
var themeNameKey = 'znaiTheme';
16+
var darkThemeName = 'znai-dark';
17+
var lightThemeName = 'default';
18+
19+
var znaiTheme = {
20+
changeHandlers: [],
21+
addChangeHandler(handler) {
22+
this.changeHandlers.push(handler);
23+
},
24+
removeChangeHandler(handler) {
25+
var idx = this.changeHandlers.indexOf(handler);
26+
this.changeHandlers.splice(idx, 1);
27+
},
28+
set(name) {
29+
this.name = name;
30+
document.body.className = 'theme-' + name;
31+
32+
var idx = 0;
33+
var len = this.changeHandlers.length;
34+
for (; idx < len; idx++) {
35+
this.changeHandlers[idx](name);
36+
}
37+
},
38+
setExplicitly(name) {
39+
storeThemeName(name);
40+
this.set(name);
41+
},
42+
setExplicitlyIfNotSetAlready(name) {
43+
const themeName = getStoredThemeName();
44+
if (themeName) {
45+
return
46+
}
47+
48+
this.setExplicitly(name)
49+
},
50+
toggle() {
51+
this.setExplicitly(this.name === lightThemeName ? darkThemeName : lightThemeName)
52+
}
53+
};
54+
55+
var mediaThemeName = setLightMatchMediaListenerAndGetThemeName()
56+
var themeName = getStoredThemeName() || mediaThemeName;
57+
znaiTheme.set(themeName);
58+
59+
window.znaiTheme = znaiTheme;
60+
61+
function getStoredThemeName() {
62+
return localStorage.getItem(themeNameKey);
63+
}
64+
65+
function storeThemeName(name) {
66+
return localStorage.setItem(themeNameKey, name);
67+
}
68+
69+
function setLightMatchMediaListenerAndGetThemeName() {
70+
if (!window.matchMedia) {
71+
return darkThemeName;
72+
}
73+
74+
var lightQuery = window.matchMedia('(prefers-color-scheme: light)');
75+
lightQuery.addListener(function (e) {
76+
const newThemeName = e.matches ? lightThemeName : darkThemeName;
77+
znaiTheme.setExplicitly(newThemeName);
78+
});
79+
80+
return lightQuery.matches ? lightThemeName : darkThemeName;
81+
}
82+
})()</script>
83+
<div id="znai"><div id="znai-initial-page-loading" style="margin: -20px 0 0 -20px; padding: 0 40px 40px 0; width: 100vw; height: 100vh; display: flex; justify-content: center; align-items: center">
84+
<div></div>
85+
</div><section style="max-width: 640px; margin-left: auto; margin-right: auto;">
86+
<article>
87+
<header><h1>Customizing the GraphQL Endpoint</h1></header>
88+
<p>By default, webtau assumes that all requests are made to a /graphql endpoint. The config value graphQLEndpoint can be set to use a non-standard endpoint, e.g. graphQLEndpoint=/api/graphql .Webtau also decorates the query with a (typically ignored) query parameter that contains the request's operationName , e.g. /graphql?operation=myOperation . This makes execution logs as well as webtau's step reports easier to read and debug, especially since the operation's name is part of the request's payload and is usually not logged by request loggers. If you want to turn this feature off, set the config value for graphQLShowOperationAsQueryParam to false .In order to customize the graphQL URL in different ways, you need to implement a GraphQLHttpConfiguration and ensure it gets loaded at runtime via the Java ServiceLoader.Here is an example in groovy: package org.testingisdocumenting.webtau.graphql import org.testingisdocumenting.webtau.graphql.config.GraphQLHttpConfiguration import org.testingisdocumenting.webtau.graphql.model.GraphQLRequest class CustomGraphQLHttpConfiguration implements GraphQLHttpConfiguration { // Note: our test server requires the graphql endpoint to start with &quot;graphql&quot; public static final CUSTOM_GRAPHQL_ENDPOINT = 'graphql-custom' @Override String requestUrl(String url, GraphQLRequest graphQLRequest) { if (null != graphQLRequest.operationName &amp;&amp; !graphQLRequest.operationName.isEmpty()) { return &quot;${CUSTOM_GRAPHQL_ENDPOINT}?operation=${graphQLRequest.operationName}&quot; } return url } }</p>
89+
</article>
90+
</section>
91+
</div>
92+
<script type="text/javascript" src="/webtau/toc.js"></script>
93+
<script type="text/javascript" src="/webtau/documentation-references.js"></script>
94+
<script type="text/javascript" src="/webtau/assets.js"></script>
95+
<script type="text/javascript" src="/webtau/static/main.js"></script>
96+
<script type="text/javascript" src="/webtau/search-index.js"></script>
97+
<script>
98+
document.getElementById('znai').innerHTML = '';
99+
/*<!--*/
100+
ReactDOM.render(React.createElement(Documentation, {
101+
"docMeta" : {
102+
"viewOn" : {
103+
"link" : "https://github.com/testingisdocumenting/webtau/tree/master/webtau-docs/znai",
104+
"title" : "View On GitHub"
105+
},
106+
"id" : "webtau",
107+
"title" : "WebTau",
108+
"type" : "Guide",
109+
"previewEnabled" : false,
110+
"allowedGroups" : [ "admin" ]
111+
},
112+
"page" : {
113+
"type" : "Page",
114+
"content" : [ {
115+
"title" : "Customizing the GraphQL Endpoint",
116+
"id" : "customizing-the-graphql-endpoint",
117+
"type" : "Section",
118+
"content" : [ {
119+
"type" : "Paragraph",
120+
"content" : [ {
121+
"text" : "By default, webtau assumes that all requests are made to a ",
122+
"type" : "SimpleText"
123+
}, {
124+
"code" : "/graphql",
125+
"type" : "InlinedCode"
126+
}, {
127+
"text" : " endpoint. The config value ",
128+
"type" : "SimpleText"
129+
}, {
130+
"code" : "graphQLEndpoint",
131+
"type" : "InlinedCode"
132+
}, {
133+
"text" : " can be set to use a non-standard endpoint, e.g. ",
134+
"type" : "SimpleText"
135+
}, {
136+
"code" : "graphQLEndpoint=/api/graphql",
137+
"type" : "InlinedCode"
138+
}, {
139+
"text" : ".",
140+
"type" : "SimpleText"
141+
} ]
142+
}, {
143+
"type" : "Paragraph",
144+
"content" : [ {
145+
"text" : "Webtau also decorates the query with a (typically ignored) query parameter that contains the request's ",
146+
"type" : "SimpleText"
147+
}, {
148+
"code" : "operationName",
149+
"type" : "InlinedCode"
150+
}, {
151+
"text" : ", e.g. ",
152+
"type" : "SimpleText"
153+
}, {
154+
"code" : "/graphql?operation=myOperation",
155+
"type" : "InlinedCode"
156+
}, {
157+
"text" : ". This makes execution logs as well as webtau's step reports easier to read and debug, especially since the operation's name is part of the request's payload and is usually not logged by request loggers.",
158+
"type" : "SimpleText"
159+
}, {
160+
"type" : "SoftLineBreak"
161+
}, {
162+
"text" : "If you want to turn this feature off, set the config value for ",
163+
"type" : "SimpleText"
164+
}, {
165+
"code" : "graphQLShowOperationAsQueryParam",
166+
"type" : "InlinedCode"
167+
}, {
168+
"text" : " to ",
169+
"type" : "SimpleText"
170+
}, {
171+
"code" : "false",
172+
"type" : "InlinedCode"
173+
}, {
174+
"text" : ".",
175+
"type" : "SimpleText"
176+
} ]
177+
}, {
178+
"type" : "Paragraph",
179+
"content" : [ {
180+
"text" : "In order to customize the graphQL URL in different ways, you need to implement a ",
181+
"type" : "SimpleText"
182+
}, {
183+
"code" : "GraphQLHttpConfiguration",
184+
"type" : "InlinedCode"
185+
}, {
186+
"text" : " and ensure it gets loaded at runtime via the Java ServiceLoader.",
187+
"type" : "SimpleText"
188+
} ]
189+
}, {
190+
"type" : "Paragraph",
191+
"content" : [ {
192+
"text" : "Here is an example in groovy:",
193+
"type" : "SimpleText"
194+
} ]
195+
}, {
196+
"lang" : "groovy",
197+
"snippet" : "package org.testingisdocumenting.webtau.graphql\n\nimport org.testingisdocumenting.webtau.graphql.config.GraphQLHttpConfiguration\nimport org.testingisdocumenting.webtau.graphql.model.GraphQLRequest\n\nclass CustomGraphQLHttpConfiguration implements GraphQLHttpConfiguration {\n // Note: our test server requires the graphql endpoint to start with \"graphql\"\n public static final CUSTOM_GRAPHQL_ENDPOINT = 'graphql-custom'\n\n @Override\n String requestUrl(String url, GraphQLRequest graphQLRequest) {\n if (null != graphQLRequest.operationName && !graphQLRequest.operationName.isEmpty()) {\n return \"${CUSTOM_GRAPHQL_ENDPOINT}?operation=${graphQLRequest.operationName}\"\n }\n return url\n }\n}",
198+
"title" : "Customized GraphQLHttpConfiguration adding the operation to the URL",
199+
"type" : "Snippet"
200+
} ]
201+
} ],
202+
"lastModifiedTime" : 1616434529902,
203+
"tocItem" : {
204+
"sectionTitle" : "GraphQL",
205+
"pageTitle" : "Customized Graphql Urls",
206+
"pageMeta" : { },
207+
"dirName" : "GraphQL",
208+
"fileName" : "customized-graphql-urls",
209+
"viewOnRelativePath" : null,
210+
"pageSectionIdTitles" : [ {
211+
"title" : "Customizing the GraphQL Endpoint",
212+
"id" : "customizing-the-graphql-endpoint"
213+
} ]
214+
}
215+
},
216+
"footer" : {
217+
"type" : "Footer",
218+
"content" : [ {
219+
"type" : "Paragraph",
220+
"content" : [ {
221+
"text" : "If you have documentation suggestions, features or bugs to report, please create ",
222+
"type" : "SimpleText"
223+
}, {
224+
"url" : "https://github.com/testingisdocumenting/webtau/issues",
225+
"isFile" : false,
226+
"type" : "Link",
227+
"content" : [ {
228+
"text" : "GitHub Issue",
229+
"type" : "SimpleText"
230+
} ]
231+
} ]
232+
}, {
233+
"type" : "Paragraph",
234+
"content" : [ {
235+
"text" : "Contributions are welcome",
236+
"type" : "SimpleText"
237+
} ]
238+
} ]
239+
}
240+
}), document.getElementById("znai"));
241+
/*-->*/
242+
243+
</script>
244+
245+
</body>
246+
</html>

GraphQL/introduction/index.html

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
<div></div>
8585
</div><section style="max-width: 640px; margin-left: auto; margin-right: auto;">
8686
<article>
87-
<p>Webtau graphql. module let you exercise and validate GraphQL API. It provides a simplified way to access JSON response of an end-point and provides DSL to execute queries and mutations. Groovy package scenarios.rest import static org.testingisdocumenting.webtau.WebTauGroovyDsl.* scenario(&quot;check weather&quot;) { def query = &quot;{ weather { temperature } }&quot;; graphql.execute(query) { weather.temperature.shouldBe &lt; 100 } } package com.example.tests.junit4 import org.junit.Test import org.junit.runner.RunWith import org.testingisdocumenting.webtau.junit4.WebTauRunner import static org.testingisdocumenting.webtau.WebTauDsl.graphql @RunWith(WebTauRunner.class) class GraphQLWeatherGroovyIT { @Test void checkWeather() { def query = &quot;{ weather { temperature } }&quot;; graphql.execute(query) { weather.temperature.shouldBe &lt; 100 } } } json { &quot;data&quot;: { &quot;weather&quot;: { &quot;temperature&quot;: 88 } } } Java package com.example.tests.junit4; import org.junit.Test; import org.junit.runner.RunWith; import org.testingisdocumenting.webtau.junit4.WebTauRunner; import static org.testingisdocumenting.webtau.WebTauDsl.*; @RunWith(WebTauRunner.class) public class GraphQLWeatherJavaIT { @Test public void checkWeather() { String query = &quot;{ weather { temperature } }&quot;; graphql.execute(query, (header, body) -&gt; { body.get(&quot;data.weather.temperature&quot;).shouldBe(lessThan(100)); }); } } json { &quot;data&quot;: { &quot;weather&quot;: { &quot;temperature&quot;: 88 } } } Before diving further into writing tests for your GraphQL server, please read through the HTTP testing documentation starting with the HTTP/data-node Data node page as much of the same core principles apply to GraphQL also.The main GraphQL specific features are covered in the subsequent pages: GraphQL/queries-and-mutations Queries and Mutations GraphQL/report Report</p>
87+
<p>The Webtau graphql. module lets you exercise and validate a GraphQL API. It provides a simplified way to access the JSON response of an end-point and provides a DSL to execute queries and mutations. Groovy package scenarios.rest import static org.testingisdocumenting.webtau.WebTauGroovyDsl.* scenario(&quot;check weather&quot;) { def query = &quot;{ weather { temperature } }&quot;; graphql.execute(query) { weather.temperature.shouldBe &lt; 100 } } package com.example.tests.junit4 import org.junit.Test import org.junit.runner.RunWith import org.testingisdocumenting.webtau.junit4.WebTauRunner import static org.testingisdocumenting.webtau.WebTauDsl.graphql @RunWith(WebTauRunner.class) class GraphQLWeatherGroovyIT { @Test void checkWeather() { def query = &quot;{ weather { temperature } }&quot;; graphql.execute(query) { weather.temperature.shouldBe &lt; 100 } } } json { &quot;data&quot;: { &quot;weather&quot;: { &quot;temperature&quot;: 88 } } } Java package com.example.tests.junit4; import org.junit.Test; import org.junit.runner.RunWith; import org.testingisdocumenting.webtau.junit4.WebTauRunner; import static org.testingisdocumenting.webtau.WebTauDsl.*; @RunWith(WebTauRunner.class) public class GraphQLWeatherJavaIT { @Test public void checkWeather() { String query = &quot;{ weather { temperature } }&quot;; graphql.execute(query, (header, body) -&gt; { body.get(&quot;data.weather.temperature&quot;).shouldBe(lessThan(100)); }); } } json { &quot;data&quot;: { &quot;weather&quot;: { &quot;temperature&quot;: 88 } } } Before diving further into writing tests for your GraphQL server, please read through the HTTP testing documentation starting with the HTTP/data-node Data node page as much of the same core principles apply to GraphQL also.The main GraphQL specific features are covered in the subsequent pages: GraphQL/queries-and-mutations Queries and Mutations GraphQL/customized-graphql-urls Customized GraphQL URLs GraphQL/report Report</p>
8888
</article>
8989
</section>
9090
</div>
@@ -113,18 +113,18 @@
113113
"content" : [ {
114114
"type" : "Paragraph",
115115
"content" : [ {
116-
"text" : "Webtau ",
116+
"text" : "The Webtau ",
117117
"type" : "SimpleText"
118118
}, {
119119
"code" : "graphql.",
120120
"type" : "InlinedCode"
121121
}, {
122-
"text" : " module let you exercise and validate GraphQL API.",
122+
"text" : " module lets you exercise and validate a GraphQL API.",
123123
"type" : "SimpleText"
124124
}, {
125125
"type" : "SoftLineBreak"
126126
}, {
127-
"text" : "It provides a simplified way to access JSON response of an end-point and provides DSL to execute queries and mutations.",
127+
"text" : "It provides a simplified way to access the JSON response of an end-point and provides a DSL to execute queries and mutations.",
128128
"type" : "SimpleText"
129129
} ]
130130
}, {
@@ -225,6 +225,20 @@
225225
} ]
226226
} ]
227227
} ]
228+
}, {
229+
"type" : "ListItem",
230+
"content" : [ {
231+
"type" : "Paragraph",
232+
"content" : [ {
233+
"url" : "/webtau/GraphQL/customized-graphql-urls",
234+
"isFile" : false,
235+
"type" : "Link",
236+
"content" : [ {
237+
"text" : "Customized GraphQL URLs",
238+
"type" : "SimpleText"
239+
} ]
240+
} ]
241+
} ]
228242
}, {
229243
"type" : "ListItem",
230244
"content" : [ {
@@ -241,7 +255,7 @@
241255
} ]
242256
} ]
243257
} ],
244-
"lastModifiedTime" : 1613786862456,
258+
"lastModifiedTime" : 1616434529902,
245259
"tocItem" : {
246260
"sectionTitle" : "GraphQL",
247261
"pageTitle" : "Introduction",

GraphQL/queries-and-mutations/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@
276276
} ]
277277
} ]
278278
} ],
279-
"lastModifiedTime" : 1613786862456,
279+
"lastModifiedTime" : 1616434529902,
280280
"tocItem" : {
281281
"sectionTitle" : "GraphQL",
282282
"pageTitle" : "Queries And Mutations",

0 commit comments

Comments
 (0)