Interface GraphQlTester
- All Known Subinterfaces:
ExecutionGraphQlServiceTester
,HttpGraphQlTester
,RSocketGraphQlTester
,WebGraphQlTester
,WebSocketGraphQlTester
- All Known Implementing Classes:
AbstractDelegatingGraphQlTester
public interface GraphQlTester
Define a workflow to test GraphQL requests that is independent of the
underlying transport.
To test using a client that connects to a server, with or without a live
server, see GraphQlTester
extensions:
To test on the server side, without a client, see the following:
- Since:
- 1.0.0
- Author:
- Rossen Stoyanchev, Brian Clozel
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
GraphQlTester.Builder<B extends GraphQlTester.Builder<B>>
A builder to create aGraphQlTester
instance.static interface
GraphQlTester.Entity<D,
S extends GraphQlTester.Entity<D, S>> Contains a decoded entity and provides options to assert it.static interface
Contains a List of decoded entities and provides options to assert them.static interface
Declare options to filter out expected errors or inspect all errors and verify there are no unexpected errors.static interface
Options available to assert the response values at the current path.static interface
GraphQlTester.Request<T extends GraphQlTester.Request<T>>
Declare options to gather input for a GraphQL request and execute it.static interface
Declare options to check the data and errors of a GraphQL response.static interface
Declare options available to assert a GraphQL Subscription response.static interface
Declare options to switch to different part of the GraphQL response. -
Method Summary
Modifier and TypeMethodDescriptionstatic GraphQlTester.Builder<?>
builder
(GraphQlTransport transport) Create a builder with a customGraphQlTransport
.Start defining a GraphQL request with the given document, which is the textual representation of an operation (or operations) to perform.documentName
(String documentName) Variant ofdocument(String)
that uses the given key to resolve the GraphQL document from a file with the help of the configuredDocumentSource
.mutate()
Create a builder initialized from the configuration of "this" tester.
-
Method Details
-
document
Start defining a GraphQL request with the given document, which is the textual representation of an operation (or operations) to perform.- Parameters:
document
- the document for the request- Returns:
- spec for response assertions
- Throws:
AssertionError
- if the response status is not 200 (OK)
-
documentName
Variant ofdocument(String)
that uses the given key to resolve the GraphQL document from a file with the help of the configuredDocumentSource
.- Parameters:
documentName
- the name of the document to send- Returns:
- spec for response assertions
- Throws:
IllegalArgumentException
- if the documentName cannot be resolvedAssertionError
- if the response status is not 200 (OK)
-
mutate
GraphQlTester.Builder<?> mutate()Create a builder initialized from the configuration of "this" tester. Use it to build a new, independently configured instance. -
builder
Create a builder with a customGraphQlTransport
.For most cases, use a transport specific extension such as
HttpGraphQlTester
orWebSocketGraphQlTester
. This method is for use with a customGraphQlTransport
.- Parameters:
transport
- the transport to execute requests with- Returns:
- the builder for further initialization
-