public class GraphQLTestTemplate
extends java.lang.Object
| Constructor and Description |
|---|
GraphQLTestTemplate(org.springframework.core.io.ResourceLoader resourceLoader,
org.springframework.boot.test.web.client.TestRestTemplate restTemplate,
java.lang.String graphqlMapping,
com.fasterxml.jackson.databind.ObjectMapper objectMapper) |
| Modifier and Type | Method and Description |
|---|---|
GraphQLResponse |
perform(java.lang.String graphqlResource,
com.fasterxml.jackson.databind.node.ObjectNode variables)
Loads a GraphQL query or mutation from the given classpath resource and sends it to the GraphQL
server.
|
GraphQLResponse |
perform(java.lang.String graphqlResource,
com.fasterxml.jackson.databind.node.ObjectNode variables,
java.util.List<java.lang.String> fragmentResources)
Loads a GraphQL query or mutation from the given classpath resource and sends it to the GraphQL
server.
|
GraphQLResponse |
perform(java.lang.String graphqlResource,
java.lang.String operationName)
Loads a GraphQL query or mutation from the given classpath resource and sends it to the GraphQL
server.
|
GraphQLResponse |
perform(java.lang.String graphqlResource,
java.lang.String operation,
com.fasterxml.jackson.databind.node.ObjectNode variables)
Loads a GraphQL query or mutation from the given classpath resource and sends it to the GraphQL
server.
|
GraphQLResponse |
perform(java.lang.String graphqlResource,
java.lang.String operationName,
com.fasterxml.jackson.databind.node.ObjectNode variables,
java.util.List<java.lang.String> fragmentResources)
Loads a GraphQL query or mutation from the given classpath resource and sends it to the GraphQL
server.
|
GraphQLResponse |
post(java.lang.String payload)
Performs a GraphQL request with the provided payload.
|
GraphQLResponse |
postForResource(java.lang.String graphqlResource)
Loads a GraphQL query or mutation from the given classpath resource and sends it to the GraphQL
server.
|
GraphQLResponse |
postForResource(java.lang.String graphqlResource,
java.util.List<java.lang.String> fragmentResources)
Loads a GraphQL query or mutation from the given classpath resource, appending any graphql
fragment resources provided and sends it to the GraphQL server.
|
GraphQLResponse |
postMultipart(java.lang.String query,
java.lang.String variables) |
GraphQLTestTemplate |
withAdditionalHeader(java.lang.String name,
java.lang.String... value)
Add an HTTP header that will be sent with each request this sends.
|
GraphQLTestTemplate |
withAdditionalHeaders(org.springframework.util.MultiValueMap<java.lang.String,java.lang.String> additionalHeaders)
Add multiple HTTP header that will be sent with each request this sends.
|
GraphQLTestTemplate |
withBasicAuth(@NonNull java.lang.String encodedCredentials)
Adds basic authentication to the authorization header.
|
GraphQLTestTemplate |
withBasicAuth(@NonNull java.lang.String username,
@NonNull java.lang.String password)
Adds basic authentication to the authorization header.
|
GraphQLTestTemplate |
withBasicAuth(@NonNull java.lang.String username,
@NonNull java.lang.String password,
java.nio.charset.Charset charset)
Adds basic authentication to the authorization header.
|
GraphQLTestTemplate |
withBearerAuth(@NonNull java.lang.String token)
Adds a bearer token to the authorization header.
|
GraphQLTestTemplate |
withClearHeaders()
Clear all associated HTTP headers.
|
GraphQLTestTemplate |
withHeaders(org.springframework.http.HttpHeaders newHeaders)
Replace any associated HTTP headers with the provided headers.
|
public GraphQLTestTemplate(org.springframework.core.io.ResourceLoader resourceLoader,
org.springframework.boot.test.web.client.TestRestTemplate restTemplate,
@Value(value="${graphql.servlet.mapping:/graphql}")
java.lang.String graphqlMapping,
com.fasterxml.jackson.databind.ObjectMapper objectMapper)
public GraphQLTestTemplate withAdditionalHeader(java.lang.String name, java.lang.String... value)
name - Name (key) of HTTP header to add.value - Value(s) of HTTP header to add.public GraphQLTestTemplate withAdditionalHeaders(org.springframework.util.MultiValueMap<java.lang.String,java.lang.String> additionalHeaders)
additionalHeaders - additional headers to addpublic GraphQLTestTemplate withBearerAuth(@NonNull @NonNull java.lang.String token)
token - the bearer tokenpublic GraphQLTestTemplate withBasicAuth(@NonNull @NonNull java.lang.String username, @NonNull @NonNull java.lang.String password, @Nullable java.nio.charset.Charset charset)
username - the usernamepassword - the passwordcharset - the charset used by the credentialspublic GraphQLTestTemplate withBasicAuth(@NonNull @NonNull java.lang.String username, @NonNull @NonNull java.lang.String password)
username - the usernamepassword - the passwordpublic GraphQLTestTemplate withBasicAuth(@NonNull @NonNull java.lang.String encodedCredentials)
encodedCredentials - the encoded credentialspublic GraphQLTestTemplate withHeaders(org.springframework.http.HttpHeaders newHeaders)
newHeaders - Headers to use.public GraphQLTestTemplate withClearHeaders()
public GraphQLResponse perform(java.lang.String graphqlResource, com.fasterxml.jackson.databind.node.ObjectNode variables) throws java.io.IOException
graphqlResource - path to the classpath resource containing the GraphQL queryvariables - the input variables for the GraphQL queryGraphQLResponse containing the result of query executionjava.io.IOException - if the resource cannot be loaded from the classpathpublic GraphQLResponse perform(java.lang.String graphqlResource, java.lang.String operationName) throws java.io.IOException
graphqlResource - path to the classpath resource containing the GraphQL queryoperationName - the name of the GraphQL operation to be executedGraphQLResponse containing the result of query executionjava.io.IOException - if the resource cannot be loaded from the classpathpublic GraphQLResponse perform(java.lang.String graphqlResource, java.lang.String operation, com.fasterxml.jackson.databind.node.ObjectNode variables) throws java.io.IOException
graphqlResource - path to the classpath resource containing the GraphQL queryoperation - the name of the GraphQL operation to be executedvariables - the input variables for the GraphQL queryGraphQLResponse containing the result of query executionjava.io.IOException - if the resource cannot be loaded from the classpathpublic GraphQLResponse perform(java.lang.String graphqlResource, com.fasterxml.jackson.databind.node.ObjectNode variables, java.util.List<java.lang.String> fragmentResources) throws java.io.IOException
graphqlResource - path to the classpath resource containing the GraphQL queryvariables - the input variables for the GraphQL queryfragmentResources - an ordered list of classpath resources containing GraphQL fragment
definitions.GraphQLResponse containing the result of query executionjava.io.IOException - if the resource cannot be loaded from the classpathpublic GraphQLResponse perform(java.lang.String graphqlResource, java.lang.String operationName, com.fasterxml.jackson.databind.node.ObjectNode variables, java.util.List<java.lang.String> fragmentResources) throws java.io.IOException
graphqlResource - path to the classpath resource containing the GraphQL queryvariables - the input variables for the GraphQL queryfragmentResources - an ordered list of classpath resources containing GraphQL fragment
definitions.GraphQLResponse containing the result of query executionjava.io.IOException - if the resource cannot be loaded from the classpathpublic GraphQLResponse postForResource(java.lang.String graphqlResource) throws java.io.IOException
graphqlResource - path to the classpath resource containing the GraphQL queryGraphQLResponse containing the result of query executionjava.io.IOException - if the resource cannot be loaded from the classpathpublic GraphQLResponse postForResource(java.lang.String graphqlResource, java.util.List<java.lang.String> fragmentResources) throws java.io.IOException
graphqlResource - path to the classpath resource containing the GraphQL queryfragmentResources - an ordered list of classpath resources containing GraphQL fragment
definitions.GraphQLResponse containing the result of query executionjava.io.IOException - if the resource cannot be loaded from the classpathpublic GraphQLResponse postMultipart(java.lang.String query, java.lang.String variables)
public GraphQLResponse post(java.lang.String payload)
payload - the GraphQL payloadGraphQLResponse containing the result of query execution