Skip to content

Commit b83685e

Browse files
deploy: d60fd3e
1 parent 9bcbdb3 commit b83685e

100 files changed

Lines changed: 4133 additions & 4148 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: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@
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>
9594
<script type="text/javascript" src="/webtau/documentation-references.js"></script>
9695
<script type="text/javascript" src="/webtau/assets.js"></script>
9796
<script type="text/javascript" src="/webtau/static/main.js"></script>
@@ -117,8 +116,8 @@
117116
"type" : "Page",
118117
"content" : [ {
119118
"id" : "customizing-the-graphql-endpoint",
120-
"type" : "Section",
121119
"title" : "Customizing the GraphQL Endpoint",
120+
"type" : "Section",
122121
"content" : [ {
123122
"type" : "Paragraph",
124123
"content" : [ {
@@ -197,13 +196,13 @@
197196
"type" : "SimpleText"
198197
} ]
199198
}, {
199+
"lang" : "groovy",
200200
"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}",
201-
"type" : "Snippet",
202201
"title" : "Customized GraphQLHttpConfiguration adding the operation to the URL",
203-
"lang" : "groovy"
202+
"type" : "Snippet"
204203
} ]
205204
} ],
206-
"lastModifiedTime" : 1658328071382,
205+
"lastModifiedTime" : 1658346107238,
207206
"tocItem" : {
208207
"sectionTitle" : "GraphQL",
209208
"pageTitle" : "Customized Graphql Urls",

GraphQL/introduction/index.html

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,12 @@
8484
<div></div>
8585
</div><section style="max-width: 640px; margin-left: auto; margin-right: auto;">
8686
<article>
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>
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 } } } 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)); }); } } 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>
9493
<script type="text/javascript" src="/webtau/documentation-references.js"></script>
9594
<script type="text/javascript" src="/webtau/assets.js"></script>
9695
<script type="text/javascript" src="/webtau/static/main.js"></script>
@@ -137,49 +136,59 @@
137136
"content" : [ {
138137
"columns" : [ {
139138
"content" : [ {
139+
"lang" : "groovy",
140140
"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}",
141-
"type" : "Snippet",
142141
"title" : "GraphQL API test (Groovy specific runner)",
143-
"lang" : "groovy"
142+
"type" : "Snippet"
144143
}, {
144+
"lang" : "groovy",
145145
"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}",
146-
"type" : "Snippet",
147146
"title" : "GraphQL API test (JUnit4)",
148-
"lang" : "groovy"
147+
"type" : "Snippet"
149148
} ]
150149
}, {
151150
"content" : [ {
152-
"snippet" : "{\n \"data\": {\n \"weather\": {\n \"temperature\": 88\n }\n }\n}\n",
153-
"type" : "Snippet",
154151
"title" : "Server Response",
155-
"lineNumber" : "",
156-
"lang" : "json"
152+
"data" : {
153+
"data" : {
154+
"weather" : {
155+
"temperature" : 88
156+
}
157+
}
158+
},
159+
"paths" : [ ],
160+
"type" : "Json"
157161
} ]
158162
} ],
159-
"type" : "Columns",
160-
"config" : { }
163+
"config" : { },
164+
"type" : "Columns"
161165
} ]
162166
}, {
163167
"name" : "Java",
164168
"content" : [ {
165169
"columns" : [ {
166170
"content" : [ {
171+
"lang" : "java",
167172
"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}",
168-
"type" : "Snippet",
169173
"title" : "GraphQL API test (JUnit4 Java)",
170-
"lang" : "java"
174+
"type" : "Snippet"
171175
} ]
172176
}, {
173177
"content" : [ {
174-
"snippet" : "{\n \"data\": {\n \"weather\": {\n \"temperature\": 88\n }\n }\n}\n",
175-
"type" : "Snippet",
176178
"title" : "Server Response",
177-
"lineNumber" : "",
178-
"lang" : "json"
179+
"data" : {
180+
"data" : {
181+
"weather" : {
182+
"temperature" : 88
183+
}
184+
}
185+
},
186+
"paths" : [ ],
187+
"type" : "Json"
179188
} ]
180189
} ],
181-
"type" : "Columns",
182-
"config" : { }
190+
"config" : { },
191+
"type" : "Columns"
183192
} ]
184193
} ],
185194
"type" : "Tabs"
@@ -194,13 +203,13 @@
194203
"text" : "starting with the ",
195204
"type" : "SimpleText"
196205
}, {
206+
"url" : "/webtau/HTTP/data-node",
197207
"isFile" : false,
198208
"type" : "Link",
199209
"content" : [ {
200210
"text" : "Data node page",
201211
"type" : "SimpleText"
202-
} ],
203-
"url" : "/webtau/HTTP/data-node"
212+
} ]
204213
}, {
205214
"text" : " as much of the same core principles apply to GraphQL also.",
206215
"type" : "SimpleText"
@@ -213,53 +222,53 @@
213222
} ]
214223
}, {
215224
"bulletMarker" : "*",
216-
"type" : "BulletList",
217225
"tight" : true,
226+
"type" : "BulletList",
218227
"content" : [ {
219228
"type" : "ListItem",
220229
"content" : [ {
221230
"type" : "Paragraph",
222231
"content" : [ {
232+
"url" : "/webtau/GraphQL/queries-and-mutations",
223233
"isFile" : false,
224234
"type" : "Link",
225235
"content" : [ {
226236
"text" : "Queries and Mutations",
227237
"type" : "SimpleText"
228-
} ],
229-
"url" : "/webtau/GraphQL/queries-and-mutations"
238+
} ]
230239
} ]
231240
} ]
232241
}, {
233242
"type" : "ListItem",
234243
"content" : [ {
235244
"type" : "Paragraph",
236245
"content" : [ {
246+
"url" : "/webtau/GraphQL/customized-graphql-urls",
237247
"isFile" : false,
238248
"type" : "Link",
239249
"content" : [ {
240250
"text" : "Customized GraphQL URLs",
241251
"type" : "SimpleText"
242-
} ],
243-
"url" : "/webtau/GraphQL/customized-graphql-urls"
252+
} ]
244253
} ]
245254
} ]
246255
}, {
247256
"type" : "ListItem",
248257
"content" : [ {
249258
"type" : "Paragraph",
250259
"content" : [ {
260+
"url" : "/webtau/GraphQL/report",
251261
"isFile" : false,
252262
"type" : "Link",
253263
"content" : [ {
254264
"text" : "Report",
255265
"type" : "SimpleText"
256-
} ],
257-
"url" : "/webtau/GraphQL/report"
266+
} ]
258267
} ]
259268
} ]
260269
} ]
261270
} ],
262-
"lastModifiedTime" : 1658328071382,
271+
"lastModifiedTime" : 1658346107238,
263272
"tocItem" : {
264273
"sectionTitle" : "GraphQL",
265274
"pageTitle" : "Introduction",

GraphQL/queries-and-mutations/index.html

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
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>
10099
<script type="text/javascript" src="/webtau/documentation-references.js"></script>
101100
<script type="text/javascript" src="/webtau/assets.js"></script>
102101
<script type="text/javascript" src="/webtau/static/main.js"></script>
@@ -122,21 +121,21 @@
122121
"type" : "Page",
123122
"content" : [ {
124123
"id" : "executing-queries-and-mutations",
125-
"type" : "Section",
126124
"title" : "Executing Queries and Mutations",
125+
"type" : "Section",
127126
"content" : [ {
128127
"type" : "Paragraph",
129128
"content" : [ {
130129
"text" : "WebTau follows GraphQL's ",
131130
"type" : "SimpleText"
132131
}, {
132+
"url" : "https://graphql.org/learn/serving-over-http/",
133133
"isFile" : false,
134134
"type" : "Link",
135135
"content" : [ {
136136
"text" : "Serving over HTTP best practices",
137137
"type" : "SimpleText"
138-
} ],
139-
"url" : "https://graphql.org/learn/serving-over-http/"
138+
} ]
140139
}, {
141140
"text" : " when invoking",
142141
"type" : "SimpleText"
@@ -165,8 +164,8 @@
165164
} ]
166165
}, {
167166
"bulletMarker" : "*",
168-
"type" : "BulletList",
169167
"tight" : true,
168+
"type" : "BulletList",
170169
"content" : [ {
171170
"type" : "ListItem",
172171
"content" : [ {
@@ -207,13 +206,13 @@
207206
"text" : " requests according to the ",
208207
"type" : "SimpleText"
209208
}, {
209+
"url" : "https://graphql.org/learn/serving-over-http/#post-request",
210210
"isFile" : false,
211211
"type" : "Link",
212212
"content" : [ {
213213
"text" : "best practices",
214214
"type" : "SimpleText"
215-
} ],
216-
"url" : "https://graphql.org/learn/serving-over-http/#post-request"
215+
} ]
217216
}, {
218217
"type" : "SoftLineBreak"
219218
}, {
@@ -239,16 +238,16 @@
239238
"type" : "SimpleText"
240239
} ]
241240
}, {
241+
"lang" : "groovy",
242242
"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}",
243-
"commentsType" : "inline",
244-
"type" : "Snippet",
245243
"title" : "GraphQL example with a query, a mutation and variables",
246-
"lang" : "groovy"
244+
"commentsType" : "inline",
245+
"type" : "Snippet"
247246
} ]
248247
}, {
249248
"id" : "response-assertions",
250-
"type" : "Section",
251249
"title" : "Response Assertions",
250+
"type" : "Section",
252251
"content" : [ {
253252
"type" : "Paragraph",
254253
"content" : [ {
@@ -280,7 +279,7 @@
280279
} ]
281280
} ]
282281
} ],
283-
"lastModifiedTime" : 1658328071382,
282+
"lastModifiedTime" : 1658346107238,
284283
"tocItem" : {
285284
"sectionTitle" : "GraphQL",
286285
"pageTitle" : "Queries And Mutations",

0 commit comments

Comments
 (0)