Skip to content

Commit b9410ba

Browse files
deploy: 1764015
1 parent c9f1df7 commit b9410ba

69 files changed

Lines changed: 2439 additions & 218 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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@
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.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.Webtau will attempt to send an introspection query in order to obtain information about the GraphQL schema. If this fails, it will not be able to record coverage information for GraphQL. Should you wish to fail the test if introspection fails, please set the graphQLIgnoreIntrospectionFailures property to false . url = &quot;http://localhost:8080/&quot; graphQLIgnoreIntrospectionFailures = false 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.34/webtau-dist-1.34-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.Webtau will attempt to send an introspection query in order to obtain information about the GraphQL schema. If this fails, it will not be able to record coverage information for GraphQL. Should you wish to fail the test if introspection fails, please set the graphQLIgnoreIntrospectionFailures property to false . url = &quot;http://localhost:8080/&quot; graphQLIgnoreIntrospectionFailures = false 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.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.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.Matchers.lessThan; import static org.testingisdocumenting.webtau.WebTauDsl.graphql; @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)); }); } } Add webtau.properties to test class path url = http://localhost graphQLIgnoreIntrospectionFailures = false</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.34&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.34&lt;/version&gt; &lt;/dependency&gt; Groovy 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.Matchers.lessThan; import static org.testingisdocumenting.webtau.WebTauDsl.graphql; @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)); }); } } Add webtau.properties to test class path url = http://localhost graphQLIgnoreIntrospectionFailures = false</p>
9494
</article>
9595

9696
<article>
@@ -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.33/webtau-dist-1.33-webtau.zip",
132+
"url" : "https://repo.maven.apache.org/maven2/org/testingisdocumenting/webtau/webtau-dist/1.34/webtau-dist-1.34-webtau.zip",
133133
"isFile" : false,
134134
"type" : "Link",
135135
"content" : [ {
@@ -294,15 +294,15 @@
294294
"name" : "Groovy",
295295
"content" : [ {
296296
"lang" : "xml",
297-
"snippet" : "<dependency>\n <groupId>org.testingisdocumenting.webtau</groupId>\n <artifactId>webtau-groovy</artifactId>\n <version>1.33</version>\n</dependency>",
297+
"snippet" : "<dependency>\n <groupId>org.testingisdocumenting.webtau</groupId>\n <artifactId>webtau-groovy</artifactId>\n <version>1.34</version>\n</dependency>",
298298
"title" : "Maven Dependency",
299299
"type" : "Snippet"
300300
} ]
301301
}, {
302302
"name" : "Java",
303303
"content" : [ {
304304
"lang" : "xml",
305-
"snippet" : "<dependency>\n <groupId>org.testingisdocumenting.webtau</groupId>\n <artifactId>webtau</artifactId>\n <version>1.33</version>\n</dependency>",
305+
"snippet" : "<dependency>\n <groupId>org.testingisdocumenting.webtau</groupId>\n <artifactId>webtau</artifactId>\n <version>1.34</version>\n</dependency>",
306306
"title" : "Maven Dependency",
307307
"type" : "Snippet"
308308
} ]
@@ -417,7 +417,7 @@
417417
} ]
418418
} ]
419419
} ],
420-
"lastModifiedTime" : 1604812521923,
420+
"lastModifiedTime" : 1605924949780,
421421
"tocItem" : {
422422
"sectionTitle" : "GraphQL",
423423
"pageTitle" : "Getting Started",

GraphQL/queries-and-mutations/index.html

Lines changed: 2 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 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>
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 } }</p>
8989
</article>
9090

9191
<article>
@@ -274,7 +274,7 @@
274274
} ]
275275
} ]
276276
} ],
277-
"lastModifiedTime" : 1604812521923,
277+
"lastModifiedTime" : 1605924949780,
278278
"tocItem" : {
279279
"sectionTitle" : "GraphQL",
280280
"pageTitle" : "Queries And Mutations",

0 commit comments

Comments
 (0)