Skip to content

Commit 45026df

Browse files
deploy: b5fa3c5
1 parent 54b3023 commit 45026df

60 files changed

Lines changed: 1082 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: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,17 @@
8585
</div><section style="max-width: 640px; margin-left: auto; margin-right: auto;">
8686
<article>
8787
<header><h1>Minimal Groovy Setup</h1></header>
88-
<p>Download and unzip https://repo.maven.apache.org/maven2/org/testingisdocumenting/webtau/webtau-dist/1.28/webtau-dist-1.28-webtau.zip webtau. Add it to your PATH . Generate webtau examples webtau --example Navigate into graphql example cd examples/graphql import static org.testingisdocumenting.webtau.WebTauGroovyDsl.* scenario('fetch types from schema') { def query = '{ __schema { types { name } } }' graphql.execute(query) { __schema.types.numberOfElements().shouldBe &gt; 0 } } To run test webtau introspection.groovy --url=http://localhost:8080 Note: using import is optional and is mainly for IDE auto completion. Imports are added implicitly during command line run. Url parameter can be moved to a webtau.cfg.groovy file. Please note that WebTau will automatically append /graphql to the url.You may also wish to add a graphQLEnabled = true property which will result in WebTau recording coverage and timing information per query for your tests. url = &quot;http://localhost:8080/&quot; graphQLEnabled = true configuration/environments Specify multiple environments to streamline test execution.</p>
88+
<p>Download and unzip https://repo.maven.apache.org/maven2/org/testingisdocumenting/webtau/webtau-dist/1.33/webtau-dist-1.33-webtau.zip webtau. Add it to your PATH . Generate webtau examples webtau --example Navigate into graphql example cd examples/graphql import static org.testingisdocumenting.webtau.WebTauGroovyDsl.* scenario('fetch types from schema') { def query = '{ __schema { types { name } } }' graphql.execute(query) { __schema.types.numberOfElements().shouldBe &gt; 0 } } To run test webtau introspection.groovy --url=http://localhost:8080 Note: using import is optional and is mainly for IDE auto completion. Imports are added implicitly during command line run. Url parameter can be moved to a webtau.cfg.groovy file. Please note that WebTau will automatically append /graphql to the url.You may also wish to add a graphQLEnabled = true property which will result in WebTau recording coverage and timing information per query for your tests. url = &quot;http://localhost:8080/&quot; graphQLEnabled = true configuration/environments Specify multiple environments to streamline test execution.</p>
8989
</article>
9090

9191
<article>
9292
<header><h1>Minimal JUnit Setup</h1></header>
93-
<p>Groovy &lt;dependency&gt; &lt;groupId&gt;org.testingisdocumenting.webtau&lt;/groupId&gt; &lt;artifactId&gt;webtau-groovy&lt;/artifactId&gt; &lt;version&gt;1.28&lt;/version&gt; &lt;/dependency&gt; Java &lt;dependency&gt; &lt;groupId&gt;org.testingisdocumenting.webtau&lt;/groupId&gt; &lt;artifactId&gt;webtau&lt;/artifactId&gt; &lt;version&gt;1.28&lt;/version&gt; &lt;/dependency&gt; Groovy package com.example.tests.junit4 import org.testingisdocumenting.webtau.junit4.WebTauRunner import org.junit.Test import org.junit.runner.RunWith import static org.testingisdocumenting.webtau.WebTauGroovyDsl.* @RunWith(WebTauRunner.class) class WeatherGroovyIT { @Test void checkWeather() { http.get(&quot;/weather&quot;) { temperature.shouldBe &lt; 100 } } } Java package com.example.tests.junit4; import org.testingisdocumenting.webtau.junit4.WebTauRunner; import org.junit.Test; import org.junit.runner.RunWith; import static org.testingisdocumenting.webtau.WebTauDsl.*; @RunWith(WebTauRunner.class) public class WeatherJavaIT { @Test public void checkWeather() { http.get(&quot;/weather&quot;, (header, body) -&gt; { body.get(&quot;temperature&quot;).shouldBe(lessThan(100)); }); } } Add webtau.properties to test class path url = http://localhost graphQLEnabled = true</p>
93+
<p>Groovy &lt;dependency&gt; &lt;groupId&gt;org.testingisdocumenting.webtau&lt;/groupId&gt; &lt;artifactId&gt;webtau-groovy&lt;/artifactId&gt; &lt;version&gt;1.33&lt;/version&gt; &lt;/dependency&gt; Java &lt;dependency&gt; &lt;groupId&gt;org.testingisdocumenting.webtau&lt;/groupId&gt; &lt;artifactId&gt;webtau&lt;/artifactId&gt; &lt;version&gt;1.33&lt;/version&gt; &lt;/dependency&gt; Groovy package com.example.tests.junit4 import org.testingisdocumenting.webtau.junit4.WebTauRunner import org.junit.Test import org.junit.runner.RunWith import static org.testingisdocumenting.webtau.WebTauGroovyDsl.* @RunWith(WebTauRunner.class) class WeatherGroovyIT { @Test void checkWeather() { http.get(&quot;/weather&quot;) { temperature.shouldBe &lt; 100 } } } Java package com.example.tests.junit4; import org.testingisdocumenting.webtau.junit4.WebTauRunner; import org.junit.Test; import org.junit.runner.RunWith; import static org.testingisdocumenting.webtau.WebTauDsl.*; @RunWith(WebTauRunner.class) public class WeatherJavaIT { @Test public void checkWeather() { http.get(&quot;/weather&quot;, (header, body) -&gt; { body.get(&quot;temperature&quot;).shouldBe(lessThan(100)); }); } } Add webtau.properties to test class path url = http://localhost graphQLEnabled = true</p>
9494
</article>
9595

9696
<article>
9797
<header><h1>GraphQL Specifics</h1></header>
98-
<p>Before diving further into writing tests for your GraphQL server, please read through the REST testing documentation starting with the REST/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 Queries GraphQL/report Report</p>
98+
<p>Before diving further into writing tests for your GraphQL server, please read through the REST testing documentation starting with the REST/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>
9999
</article>
100100
</section>
101101
</div>
@@ -129,7 +129,7 @@
129129
"text" : "Download and unzip ",
130130
"type" : "SimpleText"
131131
}, {
132-
"url" : "https://repo.maven.apache.org/maven2/org/testingisdocumenting/webtau/webtau-dist/1.28/webtau-dist-1.28-webtau.zip",
132+
"url" : "https://repo.maven.apache.org/maven2/org/testingisdocumenting/webtau/webtau-dist/1.33/webtau-dist-1.33-webtau.zip",
133133
"isFile" : false,
134134
"type" : "Link",
135135
"content" : [ {
@@ -283,15 +283,15 @@
283283
"name" : "Groovy",
284284
"content" : [ {
285285
"lang" : "xml",
286-
"snippet" : "<dependency>\n <groupId>org.testingisdocumenting.webtau</groupId>\n <artifactId>webtau-groovy</artifactId>\n <version>1.28</version>\n</dependency>",
286+
"snippet" : "<dependency>\n <groupId>org.testingisdocumenting.webtau</groupId>\n <artifactId>webtau-groovy</artifactId>\n <version>1.33</version>\n</dependency>",
287287
"title" : "Maven Dependency",
288288
"type" : "Snippet"
289289
} ]
290290
}, {
291291
"name" : "Java",
292292
"content" : [ {
293293
"lang" : "xml",
294-
"snippet" : "<dependency>\n <groupId>org.testingisdocumenting.webtau</groupId>\n <artifactId>webtau</artifactId>\n <version>1.28</version>\n</dependency>",
294+
"snippet" : "<dependency>\n <groupId>org.testingisdocumenting.webtau</groupId>\n <artifactId>webtau</artifactId>\n <version>1.33</version>\n</dependency>",
295295
"title" : "Maven Dependency",
296296
"type" : "Snippet"
297297
} ]
@@ -380,11 +380,11 @@
380380
"content" : [ {
381381
"type" : "Paragraph",
382382
"content" : [ {
383-
"url" : "/webtau/GraphQL/queries",
383+
"url" : "/webtau/GraphQL/queries-and-mutations",
384384
"isFile" : false,
385385
"type" : "Link",
386386
"content" : [ {
387-
"text" : "Queries",
387+
"text" : "Queries and Mutations",
388388
"type" : "SimpleText"
389389
} ]
390390
} ]
@@ -406,7 +406,7 @@
406406
} ]
407407
} ]
408408
} ],
409-
"lastModifiedTime" : 1597944757734,
409+
"lastModifiedTime" : 1604459318229,
410410
"tocItem" : {
411411
"sectionTitle" : "GraphQL",
412412
"pageTitle" : "Getting Started",
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
6-
<title>WebTau: Queries</title>
6+
<title>WebTau: Queries And Mutations</title>
77
<link rel="stylesheet" type="text/css" href="/webtau/static/css/katex.min.css">
88
<link rel="stylesheet" type="text/css" href="/webtau/static/main.css">
99
<link rel="stylesheet" type="text/css" href="/webtau/logo.css">
@@ -84,8 +84,8 @@
8484
<div></div>
8585
</div><section style="max-width: 640px; margin-left: auto; margin-right: auto;">
8686
<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>
87+
<header><h1>Executing Queries and Mutations</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. Requests allow providing:a query/mutation 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 body.data.allTasks.id.should == [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;] // Access response data with the full path allTasks.id.should == [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;] // Access response data via a shortcut allowing omitting of `body.data` id.should == [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;] // For single query requests, access response data via a shortcut allowing omitting of `body.data` and the query name } } 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>
8989
</article>
9090

9191
<article>
@@ -115,8 +115,8 @@
115115
"page" : {
116116
"type" : "Page",
117117
"content" : [ {
118-
"title" : "Executing Queries",
119-
"id" : "executing-queries",
118+
"title" : "Executing Queries and Mutations",
119+
"id" : "executing-queries-and-mutations",
120120
"type" : "Section",
121121
"content" : [ {
122122
"type" : "Paragraph",
@@ -154,7 +154,7 @@
154154
}, {
155155
"type" : "SoftLineBreak"
156156
}, {
157-
"text" : "Queries allow providing:",
157+
"text" : "Requests allow providing:",
158158
"type" : "SimpleText"
159159
} ]
160160
}, {
@@ -166,7 +166,7 @@
166166
"content" : [ {
167167
"type" : "Paragraph",
168168
"content" : [ {
169-
"text" : "a query string",
169+
"text" : "a query/mutation string",
170170
"type" : "SimpleText"
171171
} ]
172172
} ]
@@ -234,7 +234,7 @@
234234
} ]
235235
}, {
236236
"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}",
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 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}",
238238
"title" : "GraphQL example with a query, a mutation and variables",
239239
"commentsType" : "inline",
240240
"type" : "Snippet"
@@ -274,17 +274,17 @@
274274
} ]
275275
} ]
276276
} ],
277-
"lastModifiedTime" : 1597944757734,
277+
"lastModifiedTime" : 1604459318229,
278278
"tocItem" : {
279279
"sectionTitle" : "GraphQL",
280-
"pageTitle" : "Queries",
280+
"pageTitle" : "Queries And Mutations",
281281
"pageMeta" : { },
282282
"dirName" : "GraphQL",
283-
"fileName" : "queries",
283+
"fileName" : "queries-and-mutations",
284284
"viewOnRelativePath" : null,
285285
"pageSectionIdTitles" : [ {
286-
"title" : "Executing Queries",
287-
"id" : "executing-queries"
286+
"title" : "Executing Queries and Mutations",
287+
"id" : "executing-queries-and-mutations"
288288
}, {
289289
"title" : "Response Assertions",
290290
"id" : "response-assertions"

0 commit comments

Comments
 (0)