Skip to content

Commit 6c1de42

Browse files
deploy: 4918dac
1 parent 59e1a18 commit 6c1de42

123 files changed

Lines changed: 6064 additions & 985 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@
204204
"type" : "Snippet"
205205
} ]
206206
} ],
207-
"lastModifiedTime" : 1677186557934,
207+
"lastModifiedTime" : 1681825041900,
208208
"tocItem" : {
209209
"chapterTitle" : "GraphQL",
210210
"pageTitle" : "Customized Graphql Urls",

GraphQL/introduction/index.html

Lines changed: 3 additions & 78 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 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>
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)); }); } }</p>
8888
</article>
8989
</section>
9090
</div>
@@ -120,7 +120,7 @@
120120
"text" : "WebTau ",
121121
"type" : "SimpleText"
122122
}, {
123-
"code" : "graphql.",
123+
"code" : "graphql",
124124
"type" : "InlinedCode"
125125
}, {
126126
"text" : " module lets you exercise and validate a GraphQL API.",
@@ -198,83 +198,8 @@
198198
} ]
199199
} ],
200200
"type" : "Tabs"
201-
}, {
202-
"type" : "Paragraph",
203-
"content" : [ {
204-
"text" : "Before diving further into writing tests for your GraphQL server, please read through the HTTP testing documentation",
205-
"type" : "SimpleText"
206-
}, {
207-
"type" : "SoftLineBreak"
208-
}, {
209-
"text" : "starting with the ",
210-
"type" : "SimpleText"
211-
}, {
212-
"url" : "/webtau/HTTP/data-node",
213-
"isFile" : false,
214-
"type" : "Link",
215-
"content" : [ {
216-
"text" : "Data node page",
217-
"type" : "SimpleText"
218-
} ]
219-
}, {
220-
"text" : " as much of the same core principles apply to GraphQL also.",
221-
"type" : "SimpleText"
222-
} ]
223-
}, {
224-
"type" : "Paragraph",
225-
"content" : [ {
226-
"text" : "The main GraphQL specific features are covered in the subsequent pages:",
227-
"type" : "SimpleText"
228-
} ]
229-
}, {
230-
"bulletMarker" : "*",
231-
"tight" : true,
232-
"type" : "BulletList",
233-
"content" : [ {
234-
"type" : "ListItem",
235-
"content" : [ {
236-
"type" : "Paragraph",
237-
"content" : [ {
238-
"url" : "/webtau/GraphQL/queries-and-mutations",
239-
"isFile" : false,
240-
"type" : "Link",
241-
"content" : [ {
242-
"text" : "Queries and Mutations",
243-
"type" : "SimpleText"
244-
} ]
245-
} ]
246-
} ]
247-
}, {
248-
"type" : "ListItem",
249-
"content" : [ {
250-
"type" : "Paragraph",
251-
"content" : [ {
252-
"url" : "/webtau/GraphQL/customized-graphql-urls",
253-
"isFile" : false,
254-
"type" : "Link",
255-
"content" : [ {
256-
"text" : "Customized GraphQL URLs",
257-
"type" : "SimpleText"
258-
} ]
259-
} ]
260-
} ]
261-
}, {
262-
"type" : "ListItem",
263-
"content" : [ {
264-
"type" : "Paragraph",
265-
"content" : [ {
266-
"url" : "/webtau/GraphQL/report",
267-
"isFile" : false,
268-
"type" : "Link",
269-
"content" : [ {
270-
"text" : "Report",
271-
"type" : "SimpleText"
272-
} ]
273-
} ]
274-
} ]
275-
} ]
276201
} ],
277-
"lastModifiedTime" : 1677186557934,
202+
"lastModifiedTime" : 1681825041900,
278203
"tocItem" : {
279204
"chapterTitle" : "GraphQL",
280205
"pageTitle" : "Introduction",

GraphQL/queries-and-mutations/index.html

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
</div><section style="max-width: 640px; margin-left: auto; margin-right: auto;">
8686
<article>
8787
<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 string variables an operation name WebTau 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 } } scenario(&quot;cannot complete a completed task&quot;) { graphql.execute(completeMutation, [id: &quot;b&quot;]) { // Execute a mutation with a variables map errors.should == null complete.should == true } graphql.execute(completeMutation, [id: &quot;b&quot;]) { // force an error errors[0].message.shouldNot == null complete.should == null } }</p>
88+
<p>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 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 string variables an operation name WebTau 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 } } scenario(&quot;cannot complete a completed task&quot;) { graphql.execute(completeMutation, [id: &quot;b&quot;]) { // Execute a mutation with a variables map errors.should == null complete.should == true } graphql.execute(completeMutation, [id: &quot;b&quot;]) { // force an error errors[0].message.shouldNot == null complete.should == null } }</p>
8989
</article>
9090

9191
<article>
@@ -121,6 +121,81 @@
121121
"page" : {
122122
"type" : "Page",
123123
"content" : [ {
124+
"type" : "Paragraph",
125+
"content" : [ {
126+
"text" : "Before diving further into writing tests for your GraphQL server, please read through the HTTP testing documentation",
127+
"type" : "SimpleText"
128+
}, {
129+
"type" : "SoftLineBreak"
130+
}, {
131+
"text" : "starting with the ",
132+
"type" : "SimpleText"
133+
}, {
134+
"url" : "/webtau/HTTP/data-node",
135+
"isFile" : false,
136+
"type" : "Link",
137+
"content" : [ {
138+
"text" : "Data node page",
139+
"type" : "SimpleText"
140+
} ]
141+
}, {
142+
"text" : " as much of the same core principles apply to GraphQL also.",
143+
"type" : "SimpleText"
144+
} ]
145+
}, {
146+
"type" : "Paragraph",
147+
"content" : [ {
148+
"text" : "The main GraphQL specific features are covered in the subsequent pages:",
149+
"type" : "SimpleText"
150+
} ]
151+
}, {
152+
"bulletMarker" : "*",
153+
"tight" : true,
154+
"type" : "BulletList",
155+
"content" : [ {
156+
"type" : "ListItem",
157+
"content" : [ {
158+
"type" : "Paragraph",
159+
"content" : [ {
160+
"url" : "/webtau/GraphQL/queries-and-mutations",
161+
"isFile" : false,
162+
"type" : "Link",
163+
"content" : [ {
164+
"text" : "Queries and Mutations",
165+
"type" : "SimpleText"
166+
} ]
167+
} ]
168+
} ]
169+
}, {
170+
"type" : "ListItem",
171+
"content" : [ {
172+
"type" : "Paragraph",
173+
"content" : [ {
174+
"url" : "/webtau/GraphQL/customized-graphql-urls",
175+
"isFile" : false,
176+
"type" : "Link",
177+
"content" : [ {
178+
"text" : "Customized GraphQL URLs",
179+
"type" : "SimpleText"
180+
} ]
181+
} ]
182+
} ]
183+
}, {
184+
"type" : "ListItem",
185+
"content" : [ {
186+
"type" : "Paragraph",
187+
"content" : [ {
188+
"url" : "/webtau/GraphQL/report",
189+
"isFile" : false,
190+
"type" : "Link",
191+
"content" : [ {
192+
"text" : "Report",
193+
"type" : "SimpleText"
194+
} ]
195+
} ]
196+
} ]
197+
} ]
198+
}, {
124199
"id" : "executing-queries-and-mutations",
125200
"title" : "Executing Queries and Mutations",
126201
"type" : "Section",
@@ -281,7 +356,7 @@
281356
} ]
282357
} ]
283358
} ],
284-
"lastModifiedTime" : 1677186557934,
359+
"lastModifiedTime" : 1681825041900,
285360
"tocItem" : {
286361
"chapterTitle" : "GraphQL",
287362
"pageTitle" : "Queries And Mutations",

0 commit comments

Comments
 (0)