Skip to content

Commit 54b3023

Browse files
deploy: 1c19afc
1 parent a1d6a53 commit 54b3023

59 files changed

Lines changed: 1407 additions & 162 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.

GraphQL/getting-started/index.html

Lines changed: 437 additions & 0 deletions
Large diffs are not rendered by default.

GraphQL/queries/index.html

Lines changed: 299 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,299 @@
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: Queries</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>Executing Queries</h1></header>
88+
<p>WebTau follows GraphQL's https://graphql.org/learn/serving-over-http/ Serving over HTTP best practices when invoking GraphQL servers over HTTP.It therefore assumes the server responds to requests to /graphql so you do not need to specify that in the URL in your configuration. Queries allow providing:a query stringvariablesan operation nameWebTau will default to issuing POST requests according to the https://graphql.org/learn/serving-over-http/#post-request best practices and will expect a 200 status code and a response with a data or errors field.The following example demonstrates most of these query features: package scenarios.graphql import static org.testingisdocumenting.webtau.WebTauGroovyDsl.* def listAllQuery = ''' { allTasks(uncompletedOnly: false) { id description } } ''' def taskByIdQuery = ''' query taskById($id: ID!) { taskById(id: $id) { id description completed } } ''' def completeMutation = ''' mutation complete($id: ID!) { complete(id: $id) } ''' scenario(&quot;list all tasks&quot;) { graphql.execute(listAllQuery) { // Execute a simple query with no variables errors.should == null // Validate there were no errors allTasks.id.should == [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;] // Access response data via a shortcut allowing omitting of `body.data` body.data.allTasks.id.should == [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;] } } scenario(&quot;complete a task&quot;) { graphql.execute(completeMutation, [id: &quot;a&quot;]) { // Execute a mutation with a variables map errors.should == null complete.should == true } graphql.execute(taskByIdQuery, [id: &quot;a&quot;]) { errors.should == null taskById.id.should == &quot;a&quot; taskById.completed.should == true } }</p>
89+
</article>
90+
91+
<article>
92+
<header><h1>Response Assertions</h1></header>
93+
<p>Response assertions follow a similar pattern to REST APIs.For Groovy specifically, there are shortcuts for accessing data in the response directly as demonstrated in the example above. You may access errors directly via errors or fields in the response directly with the field names, omitting the data field.</p>
94+
</article>
95+
</section>
96+
</div>
97+
<script type="text/javascript" src="/webtau/toc.js"></script>
98+
<script type="text/javascript" src="/webtau/assets.js"></script>
99+
<script type="text/javascript" src="/webtau/static/main.js"></script>
100+
<script type="text/javascript" src="/webtau/search-index.js"></script>
101+
<script>
102+
document.getElementById('znai').innerHTML = '';
103+
ReactDOM.render(React.createElement(Documentation, {
104+
"docMeta" : {
105+
"viewOn" : {
106+
"link" : "https://github.com/testingisdocumenting/webtau/tree/master/webtau-docs/znai",
107+
"title" : "View On GitHub"
108+
},
109+
"id" : "webtau",
110+
"title" : "WebTau",
111+
"type" : "Guide",
112+
"previewEnabled" : false,
113+
"allowedGroups" : [ "admin" ]
114+
},
115+
"page" : {
116+
"type" : "Page",
117+
"content" : [ {
118+
"title" : "Executing Queries",
119+
"id" : "executing-queries",
120+
"type" : "Section",
121+
"content" : [ {
122+
"type" : "Paragraph",
123+
"content" : [ {
124+
"text" : "WebTau follows GraphQL's ",
125+
"type" : "SimpleText"
126+
}, {
127+
"url" : "https://graphql.org/learn/serving-over-http/",
128+
"isFile" : false,
129+
"type" : "Link",
130+
"content" : [ {
131+
"text" : "Serving over HTTP best practices",
132+
"type" : "SimpleText"
133+
} ]
134+
}, {
135+
"text" : " when invoking",
136+
"type" : "SimpleText"
137+
}, {
138+
"type" : "SoftLineBreak"
139+
}, {
140+
"text" : "GraphQL servers over HTTP.",
141+
"type" : "SimpleText"
142+
} ]
143+
}, {
144+
"type" : "Paragraph",
145+
"content" : [ {
146+
"text" : "It therefore assumes the server responds to requests to ",
147+
"type" : "SimpleText"
148+
}, {
149+
"code" : "/graphql",
150+
"type" : "InlinedCode"
151+
}, {
152+
"text" : " so you do not need to specify that in the URL in your configuration.",
153+
"type" : "SimpleText"
154+
}, {
155+
"type" : "SoftLineBreak"
156+
}, {
157+
"text" : "Queries allow providing:",
158+
"type" : "SimpleText"
159+
} ]
160+
}, {
161+
"bulletMarker" : "*",
162+
"tight" : true,
163+
"type" : "BulletList",
164+
"content" : [ {
165+
"type" : "ListItem",
166+
"content" : [ {
167+
"type" : "Paragraph",
168+
"content" : [ {
169+
"text" : "a query string",
170+
"type" : "SimpleText"
171+
} ]
172+
} ]
173+
}, {
174+
"type" : "ListItem",
175+
"content" : [ {
176+
"type" : "Paragraph",
177+
"content" : [ {
178+
"text" : "variables",
179+
"type" : "SimpleText"
180+
} ]
181+
} ]
182+
}, {
183+
"type" : "ListItem",
184+
"content" : [ {
185+
"type" : "Paragraph",
186+
"content" : [ {
187+
"text" : "an operation name",
188+
"type" : "SimpleText"
189+
} ]
190+
} ]
191+
} ]
192+
}, {
193+
"type" : "Paragraph",
194+
"content" : [ {
195+
"text" : "WebTau will default to issuing ",
196+
"type" : "SimpleText"
197+
}, {
198+
"code" : "POST",
199+
"type" : "InlinedCode"
200+
}, {
201+
"text" : " requests according to the ",
202+
"type" : "SimpleText"
203+
}, {
204+
"url" : "https://graphql.org/learn/serving-over-http/#post-request",
205+
"isFile" : false,
206+
"type" : "Link",
207+
"content" : [ {
208+
"text" : "best practices",
209+
"type" : "SimpleText"
210+
} ]
211+
}, {
212+
"type" : "SoftLineBreak"
213+
}, {
214+
"text" : "and will expect a 200 status code and a response with a ",
215+
"type" : "SimpleText"
216+
}, {
217+
"code" : "data",
218+
"type" : "InlinedCode"
219+
}, {
220+
"text" : " or ",
221+
"type" : "SimpleText"
222+
}, {
223+
"code" : "errors",
224+
"type" : "InlinedCode"
225+
}, {
226+
"text" : " field.",
227+
"type" : "SimpleText"
228+
} ]
229+
}, {
230+
"type" : "Paragraph",
231+
"content" : [ {
232+
"text" : "The following example demonstrates most of these query features:",
233+
"type" : "SimpleText"
234+
} ]
235+
}, {
236+
"lang" : "groovy",
237+
"snippet" : "package scenarios.graphql\n\nimport static org.testingisdocumenting.webtau.WebTauGroovyDsl.*\n\ndef listAllQuery = '''\n{\n allTasks(uncompletedOnly: false) {\n id\n description\n }\n}\n'''\n\ndef taskByIdQuery = '''\nquery taskById($id: ID!) {\n taskById(id: $id) {\n id\n description\n completed\n }\n}\n'''\n\ndef completeMutation = '''\nmutation complete($id: ID!) {\n complete(id: $id)\n}\n'''\n\nscenario(\"list all tasks\") {\n graphql.execute(listAllQuery) { // Execute a simple query with no variables\n errors.should == null // Validate there were no errors\n allTasks.id.should == [\"a\", \"b\", \"c\"] // Access response data via a shortcut allowing omitting of `body.data`\n body.data.allTasks.id.should == [\"a\", \"b\", \"c\"]\n }\n}\n\nscenario(\"complete a task\") {\n graphql.execute(completeMutation, [id: \"a\"]) { // Execute a mutation with a variables map\n errors.should == null\n complete.should == true\n }\n\n graphql.execute(taskByIdQuery, [id: \"a\"]) {\n errors.should == null\n taskById.id.should == \"a\"\n taskById.completed.should == true\n }\n}",
238+
"title" : "GraphQL example with a query, a mutation and variables",
239+
"commentsType" : "inline",
240+
"type" : "Snippet"
241+
} ]
242+
}, {
243+
"title" : "Response Assertions",
244+
"id" : "response-assertions",
245+
"type" : "Section",
246+
"content" : [ {
247+
"type" : "Paragraph",
248+
"content" : [ {
249+
"text" : "Response assertions follow a similar pattern to REST APIs.",
250+
"type" : "SimpleText"
251+
} ]
252+
}, {
253+
"type" : "Paragraph",
254+
"content" : [ {
255+
"text" : "For Groovy specifically, there are shortcuts for accessing data in the response directly as demonstrated in the example above.",
256+
"type" : "SimpleText"
257+
}, {
258+
"type" : "SoftLineBreak"
259+
}, {
260+
"text" : "You may access errors directly via ",
261+
"type" : "SimpleText"
262+
}, {
263+
"code" : "errors",
264+
"type" : "InlinedCode"
265+
}, {
266+
"text" : " or fields in the response directly with the field names, omitting the ",
267+
"type" : "SimpleText"
268+
}, {
269+
"code" : "data",
270+
"type" : "InlinedCode"
271+
}, {
272+
"text" : " field.",
273+
"type" : "SimpleText"
274+
} ]
275+
} ]
276+
} ],
277+
"lastModifiedTime" : 1597944757734,
278+
"tocItem" : {
279+
"sectionTitle" : "GraphQL",
280+
"pageTitle" : "Queries",
281+
"pageMeta" : { },
282+
"dirName" : "GraphQL",
283+
"fileName" : "queries",
284+
"viewOnRelativePath" : null,
285+
"pageSectionIdTitles" : [ {
286+
"title" : "Executing Queries",
287+
"id" : "executing-queries"
288+
}, {
289+
"title" : "Response Assertions",
290+
"id" : "response-assertions"
291+
} ]
292+
}
293+
},
294+
"footer" : { }
295+
}), document.getElementById("znai"));
296+
</script>
297+
298+
</body>
299+
</html>

0 commit comments

Comments
 (0)