Skip to content

Commit e94ff30

Browse files
deploy: 55eedd0
1 parent 05107f9 commit e94ff30

100 files changed

Lines changed: 3349 additions & 1402 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 & 5 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>Customizing the GraphQL Endpoint</h1></header>
88-
<p>By default, webtau assumes that all requests are made to a /graphql endpoint. The config value graphQLEndpoint can be set to use a non-standard endpoint, e.g. graphQLEndpoint=/api/graphql .Webtau also decorates the query with a (typically ignored) query parameter that contains the request's operationName , e.g. /graphql?operation=myOperation . This makes execution logs as well as webtau's step reports easier to read and debug, especially since the operation's name is part of the request's payload and is usually not logged by request loggers. If you want to turn this feature off, set the config value for graphQLShowOperationAsQueryParam to false .In order to customize the graphQL URL in different ways, you need to implement a GraphQLHttpConfiguration and ensure it gets loaded at runtime via the Java ServiceLoader.Here is an example in groovy: package org.testingisdocumenting.webtau.graphql import org.testingisdocumenting.webtau.graphql.config.GraphQLHttpConfiguration import org.testingisdocumenting.webtau.graphql.model.GraphQLRequest class CustomGraphQLHttpConfiguration implements GraphQLHttpConfiguration { // Note: our test server requires the graphql endpoint to start with &quot;graphql&quot; public static final CUSTOM_GRAPHQL_ENDPOINT = 'graphql-custom' @Override String requestUrl(String url, GraphQLRequest graphQLRequest) { if (null != graphQLRequest.operationName &amp;&amp; !graphQLRequest.operationName.isEmpty()) { return &quot;${CUSTOM_GRAPHQL_ENDPOINT}?operation=${graphQLRequest.operationName}&quot; } return url } }</p>
88+
<p>By default, WebTau assumes that all requests are made to a /graphql endpoint. The config value graphQLEndpoint can be set to use a non-standard endpoint, e.g. graphQLEndpoint=/api/graphql .WebTau also decorates the query with a (typically ignored) query parameter that contains the request's operationName , e.g. /graphql?operation=myOperation . This makes execution logs as well as WebTau's step reports easier to read and debug, especially since the operation's name is part of the request's payload and is usually not logged by request loggers. If you want to turn this feature off, set the config value for graphQLShowOperationAsQueryParam to false .In order to customize the graphQL URL in different ways, you need to implement a GraphQLHttpConfiguration and ensure it gets loaded at runtime via the Java ServiceLoader.Here is an example in groovy: package org.testingisdocumenting.webtau.graphql import org.testingisdocumenting.webtau.graphql.config.GraphQLHttpConfiguration import org.testingisdocumenting.webtau.graphql.model.GraphQLRequest class CustomGraphQLHttpConfiguration implements GraphQLHttpConfiguration { // Note: our test server requires the graphql endpoint to start with &quot;graphql&quot; public static final CUSTOM_GRAPHQL_ENDPOINT = 'graphql-custom' @Override String requestUrl(String url, GraphQLRequest graphQLRequest) { if (null != graphQLRequest.operationName &amp;&amp; !graphQLRequest.operationName.isEmpty()) { return &quot;${CUSTOM_GRAPHQL_ENDPOINT}?operation=${graphQLRequest.operationName}&quot; } return url } }</p>
8989
</article>
9090
</section>
9191
</div>
@@ -120,7 +120,7 @@
120120
"content" : [ {
121121
"type" : "Paragraph",
122122
"content" : [ {
123-
"text" : "By default, webtau assumes that all requests are made to a ",
123+
"text" : "By default, WebTau assumes that all requests are made to a ",
124124
"type" : "SimpleText"
125125
}, {
126126
"code" : "/graphql",
@@ -144,7 +144,7 @@
144144
}, {
145145
"type" : "Paragraph",
146146
"content" : [ {
147-
"text" : "Webtau also decorates the query with a (typically ignored) query parameter that contains the request's ",
147+
"text" : "WebTau also decorates the query with a (typically ignored) query parameter that contains the request's ",
148148
"type" : "SimpleText"
149149
}, {
150150
"code" : "operationName",
@@ -156,7 +156,7 @@
156156
"code" : "/graphql?operation=myOperation",
157157
"type" : "InlinedCode"
158158
}, {
159-
"text" : ". This makes execution logs as well as webtau's step reports easier to read and debug, especially since the operation's name is part of the request's payload and is usually not logged by request loggers.",
159+
"text" : ". This makes execution logs as well as WebTau's step reports easier to read and debug, especially since the operation's name is part of the request's payload and is usually not logged by request loggers.",
160160
"type" : "SimpleText"
161161
}, {
162162
"type" : "SoftLineBreak"
@@ -201,7 +201,7 @@
201201
"lang" : "groovy"
202202
} ]
203203
} ],
204-
"lastModifiedTime" : 1641786403222,
204+
"lastModifiedTime" : 1653501103760,
205205
"tocItem" : {
206206
"sectionTitle" : "GraphQL",
207207
"pageTitle" : "Customized Graphql Urls",

GraphQL/introduction/index.html

Lines changed: 3 additions & 3 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 } } } 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>
@@ -115,7 +115,7 @@
115115
"content" : [ {
116116
"type" : "Paragraph",
117117
"content" : [ {
118-
"text" : "Webtau ",
118+
"text" : "WebTau ",
119119
"type" : "SimpleText"
120120
}, {
121121
"code" : "graphql.",
@@ -257,7 +257,7 @@
257257
} ]
258258
} ]
259259
} ],
260-
"lastModifiedTime" : 1641786403222,
260+
"lastModifiedTime" : 1653501103760,
261261
"tocItem" : {
262262
"sectionTitle" : "GraphQL",
263263
"pageTitle" : "Introduction",

GraphQL/queries-and-mutations/index.html

Lines changed: 4 additions & 4 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>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>
@@ -125,7 +125,7 @@
125125
"content" : [ {
126126
"type" : "Paragraph",
127127
"content" : [ {
128-
"text" : "Webtau follows GraphQL's ",
128+
"text" : "WebTau follows GraphQL's ",
129129
"type" : "SimpleText"
130130
}, {
131131
"isFile" : false,
@@ -196,7 +196,7 @@
196196
}, {
197197
"type" : "Paragraph",
198198
"content" : [ {
199-
"text" : "Webtau will default to issuing ",
199+
"text" : "WebTau will default to issuing ",
200200
"type" : "SimpleText"
201201
}, {
202202
"code" : "POST",
@@ -278,7 +278,7 @@
278278
} ]
279279
} ]
280280
} ],
281-
"lastModifiedTime" : 1641786403222,
281+
"lastModifiedTime" : 1653501103760,
282282
"tocItem" : {
283283
"sectionTitle" : "GraphQL",
284284
"pageTitle" : "Queries And Mutations",

0 commit comments

Comments
 (0)