Skip to content

Commit bb00a69

Browse files
deploy: adca396
1 parent 2942820 commit bb00a69

96 files changed

Lines changed: 5045 additions & 2538 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/customized-graphql-urls/index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
</div>
9292
<script type="text/javascript" src="/webtau/footer.js"></script>
9393
<script type="text/javascript" src="/webtau/toc.js"></script>
94+
<script type="text/javascript" src="/webtau/global-anchors.js"></script>
9495
<script type="text/javascript" src="/webtau/documentation-references.js"></script>
9596
<script type="text/javascript" src="/webtau/assets.js"></script>
9697
<script type="text/javascript" src="/webtau/static/main.js"></script>
@@ -113,9 +114,9 @@
113114
"page" : {
114115
"type" : "Page",
115116
"content" : [ {
116-
"title" : "Customizing the GraphQL Endpoint",
117117
"id" : "customizing-the-graphql-endpoint",
118118
"type" : "Section",
119+
"title" : "Customizing the GraphQL Endpoint",
119120
"content" : [ {
120121
"type" : "Paragraph",
121122
"content" : [ {
@@ -194,13 +195,13 @@
194195
"type" : "SimpleText"
195196
} ]
196197
}, {
197-
"lang" : "groovy",
198198
"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}",
199+
"type" : "Snippet",
199200
"title" : "Customized GraphQLHttpConfiguration adding the operation to the URL",
200-
"type" : "Snippet"
201+
"lang" : "groovy"
201202
} ]
202203
} ],
203-
"lastModifiedTime" : 1634267317640,
204+
"lastModifiedTime" : 1640922026328,
204205
"tocItem" : {
205206
"sectionTitle" : "GraphQL",
206207
"pageTitle" : "Customized Graphql Urls",

GraphQL/introduction/index.html

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,13 @@
8484
<div></div>
8585
</div><section style="max-width: 640px; margin-left: auto; margin-right: auto;">
8686
<article>
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>
87+
<p>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>
9191
<script type="text/javascript" src="/webtau/footer.js"></script>
9292
<script type="text/javascript" src="/webtau/toc.js"></script>
93+
<script type="text/javascript" src="/webtau/global-anchors.js"></script>
9394
<script type="text/javascript" src="/webtau/documentation-references.js"></script>
9495
<script type="text/javascript" src="/webtau/assets.js"></script>
9596
<script type="text/javascript" src="/webtau/static/main.js"></script>
@@ -114,7 +115,7 @@
114115
"content" : [ {
115116
"type" : "Paragraph",
116117
"content" : [ {
117-
"text" : "The Webtau ",
118+
"text" : "Webtau ",
118119
"type" : "SimpleText"
119120
}, {
120121
"code" : "graphql.",
@@ -134,49 +135,49 @@
134135
"content" : [ {
135136
"columns" : [ {
136137
"content" : [ {
137-
"lang" : "groovy",
138138
"snippet" : "package scenarios.rest\n\nimport static org.testingisdocumenting.webtau.WebTauGroovyDsl.*\n\nscenario(\"check weather\") {\n def query = \"{ weather { temperature } }\";\n graphql.execute(query) {\n weather.temperature.shouldBe < 100\n }\n}",
139+
"type" : "Snippet",
139140
"title" : "GraphQL API test (Groovy specific runner)",
140-
"type" : "Snippet"
141+
"lang" : "groovy"
141142
}, {
142-
"lang" : "groovy",
143143
"snippet" : "package com.example.tests.junit4\n\nimport org.junit.Test\nimport org.junit.runner.RunWith\nimport org.testingisdocumenting.webtau.junit4.WebTauRunner\n\nimport static org.testingisdocumenting.webtau.WebTauDsl.graphql\n\n@RunWith(WebTauRunner.class)\nclass GraphQLWeatherGroovyIT {\n @Test\n void checkWeather() {\n def query = \"{ weather { temperature } }\";\n graphql.execute(query) {\n weather.temperature.shouldBe < 100\n }\n }\n}",
144+
"type" : "Snippet",
144145
"title" : "GraphQL API test (JUnit4)",
145-
"type" : "Snippet"
146+
"lang" : "groovy"
146147
} ]
147148
}, {
148149
"content" : [ {
149-
"lang" : "json",
150150
"snippet" : "{\n \"data\": {\n \"weather\": {\n \"temperature\": 88\n }\n }\n}\n",
151-
"lineNumber" : "",
151+
"type" : "Snippet",
152152
"title" : "Server Response",
153-
"type" : "Snippet"
153+
"lineNumber" : "",
154+
"lang" : "json"
154155
} ]
155156
} ],
156-
"config" : { },
157-
"type" : "Columns"
157+
"type" : "Columns",
158+
"config" : { }
158159
} ]
159160
}, {
160161
"name" : "Java",
161162
"content" : [ {
162163
"columns" : [ {
163164
"content" : [ {
164-
"lang" : "java",
165165
"snippet" : "package com.example.tests.junit4;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.testingisdocumenting.webtau.junit4.WebTauRunner;\n\nimport static org.testingisdocumenting.webtau.WebTauDsl.*;\n\n@RunWith(WebTauRunner.class)\npublic class GraphQLWeatherJavaIT {\n @Test\n public void checkWeather() {\n String query = \"{ weather { temperature } }\";\n graphql.execute(query, (header, body) -> {\n body.get(\"data.weather.temperature\").shouldBe(lessThan(100));\n });\n }\n}",
166+
"type" : "Snippet",
166167
"title" : "GraphQL API test (JUnit4 Java)",
167-
"type" : "Snippet"
168+
"lang" : "java"
168169
} ]
169170
}, {
170171
"content" : [ {
171-
"lang" : "json",
172172
"snippet" : "{\n \"data\": {\n \"weather\": {\n \"temperature\": 88\n }\n }\n}\n",
173-
"lineNumber" : "",
173+
"type" : "Snippet",
174174
"title" : "Server Response",
175-
"type" : "Snippet"
175+
"lineNumber" : "",
176+
"lang" : "json"
176177
} ]
177178
} ],
178-
"config" : { },
179-
"type" : "Columns"
179+
"type" : "Columns",
180+
"config" : { }
180181
} ]
181182
} ],
182183
"type" : "Tabs"
@@ -191,13 +192,13 @@
191192
"text" : "starting with the ",
192193
"type" : "SimpleText"
193194
}, {
194-
"url" : "/webtau/HTTP/data-node",
195195
"isFile" : false,
196196
"type" : "Link",
197197
"content" : [ {
198198
"text" : "Data node page",
199199
"type" : "SimpleText"
200-
} ]
200+
} ],
201+
"url" : "/webtau/HTTP/data-node"
201202
}, {
202203
"text" : " as much of the same core principles apply to GraphQL also.",
203204
"type" : "SimpleText"
@@ -210,53 +211,53 @@
210211
} ]
211212
}, {
212213
"bulletMarker" : "*",
213-
"tight" : true,
214214
"type" : "BulletList",
215+
"tight" : true,
215216
"content" : [ {
216217
"type" : "ListItem",
217218
"content" : [ {
218219
"type" : "Paragraph",
219220
"content" : [ {
220-
"url" : "/webtau/GraphQL/queries-and-mutations",
221221
"isFile" : false,
222222
"type" : "Link",
223223
"content" : [ {
224224
"text" : "Queries and Mutations",
225225
"type" : "SimpleText"
226-
} ]
226+
} ],
227+
"url" : "/webtau/GraphQL/queries-and-mutations"
227228
} ]
228229
} ]
229230
}, {
230231
"type" : "ListItem",
231232
"content" : [ {
232233
"type" : "Paragraph",
233234
"content" : [ {
234-
"url" : "/webtau/GraphQL/customized-graphql-urls",
235235
"isFile" : false,
236236
"type" : "Link",
237237
"content" : [ {
238238
"text" : "Customized GraphQL URLs",
239239
"type" : "SimpleText"
240-
} ]
240+
} ],
241+
"url" : "/webtau/GraphQL/customized-graphql-urls"
241242
} ]
242243
} ]
243244
}, {
244245
"type" : "ListItem",
245246
"content" : [ {
246247
"type" : "Paragraph",
247248
"content" : [ {
248-
"url" : "/webtau/GraphQL/report",
249249
"isFile" : false,
250250
"type" : "Link",
251251
"content" : [ {
252252
"text" : "Report",
253253
"type" : "SimpleText"
254-
} ]
254+
} ],
255+
"url" : "/webtau/GraphQL/report"
255256
} ]
256257
} ]
257258
} ]
258259
} ],
259-
"lastModifiedTime" : 1634267317640,
260+
"lastModifiedTime" : 1640922026328,
260261
"tocItem" : {
261262
"sectionTitle" : "GraphQL",
262263
"pageTitle" : "Introduction",

GraphQL/queries-and-mutations/index.html

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
</div>
9797
<script type="text/javascript" src="/webtau/footer.js"></script>
9898
<script type="text/javascript" src="/webtau/toc.js"></script>
99+
<script type="text/javascript" src="/webtau/global-anchors.js"></script>
99100
<script type="text/javascript" src="/webtau/documentation-references.js"></script>
100101
<script type="text/javascript" src="/webtau/assets.js"></script>
101102
<script type="text/javascript" src="/webtau/static/main.js"></script>
@@ -118,22 +119,22 @@
118119
"page" : {
119120
"type" : "Page",
120121
"content" : [ {
121-
"title" : "Executing Queries and Mutations",
122122
"id" : "executing-queries-and-mutations",
123123
"type" : "Section",
124+
"title" : "Executing Queries and Mutations",
124125
"content" : [ {
125126
"type" : "Paragraph",
126127
"content" : [ {
127128
"text" : "Webtau follows GraphQL's ",
128129
"type" : "SimpleText"
129130
}, {
130-
"url" : "https://graphql.org/learn/serving-over-http/",
131131
"isFile" : false,
132132
"type" : "Link",
133133
"content" : [ {
134134
"text" : "Serving over HTTP best practices",
135135
"type" : "SimpleText"
136-
} ]
136+
} ],
137+
"url" : "https://graphql.org/learn/serving-over-http/"
137138
}, {
138139
"text" : " when invoking",
139140
"type" : "SimpleText"
@@ -162,8 +163,8 @@
162163
} ]
163164
}, {
164165
"bulletMarker" : "*",
165-
"tight" : true,
166166
"type" : "BulletList",
167+
"tight" : true,
167168
"content" : [ {
168169
"type" : "ListItem",
169170
"content" : [ {
@@ -204,13 +205,13 @@
204205
"text" : " requests according to the ",
205206
"type" : "SimpleText"
206207
}, {
207-
"url" : "https://graphql.org/learn/serving-over-http/#post-request",
208208
"isFile" : false,
209209
"type" : "Link",
210210
"content" : [ {
211211
"text" : "best practices",
212212
"type" : "SimpleText"
213-
} ]
213+
} ],
214+
"url" : "https://graphql.org/learn/serving-over-http/#post-request"
214215
}, {
215216
"type" : "SoftLineBreak"
216217
}, {
@@ -236,16 +237,16 @@
236237
"type" : "SimpleText"
237238
} ]
238239
}, {
239-
"lang" : "groovy",
240240
"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 body.data.allTasks.id.should == [\"a\", \"b\", \"c\"] // Access response data with the full path\n allTasks.id.should == [\"a\", \"b\", \"c\"] // Access response data via a shortcut allowing omitting of `body.data`\n id.should == [\"a\", \"b\", \"c\"] // For single query requests, access response data via a shortcut allowing omitting of `body.data` and the query name\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}\n\nscenario(\"cannot complete a completed task\") {\n graphql.execute(completeMutation, [id: \"b\"]) { // Execute a mutation with a variables map\n errors.should == null\n complete.should == true\n }\n graphql.execute(completeMutation, [id: \"b\"]) { // force an error\n errors[0].message.shouldNot == null\n complete.should == null\n }\n}",
241-
"title" : "GraphQL example with a query, a mutation and variables",
242241
"commentsType" : "inline",
243-
"type" : "Snippet"
242+
"type" : "Snippet",
243+
"title" : "GraphQL example with a query, a mutation and variables",
244+
"lang" : "groovy"
244245
} ]
245246
}, {
246-
"title" : "Response Assertions",
247247
"id" : "response-assertions",
248248
"type" : "Section",
249+
"title" : "Response Assertions",
249250
"content" : [ {
250251
"type" : "Paragraph",
251252
"content" : [ {
@@ -277,7 +278,7 @@
277278
} ]
278279
} ]
279280
} ],
280-
"lastModifiedTime" : 1634267317640,
281+
"lastModifiedTime" : 1640922026328,
281282
"tocItem" : {
282283
"sectionTitle" : "GraphQL",
283284
"pageTitle" : "Queries And Mutations",

0 commit comments

Comments
 (0)