Refine use of "query" in type and method names
Following revisions in the spec https://github.com/graphql/graphql-spec/pull/777, this commit applies similar changes to type and method names where feasible. The chief exception for now is the use of "query" for request input since that is what it is called in the JSON for GraphQL over HTTP.
This commit is contained in:
@@ -94,8 +94,8 @@ class DefaultGraphQLTester implements GraphQLTester {
|
||||
|
||||
|
||||
@Override
|
||||
public QuerySpec query(String query) {
|
||||
return new DefaultQuerySpec(query);
|
||||
public RequestSpec query(String query) {
|
||||
return new DefaultRequestSpec(query);
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ class DefaultGraphQLTester implements GraphQLTester {
|
||||
interface RequestStrategy {
|
||||
|
||||
/**
|
||||
* Perform a query with the given {@link RequestInput} container.
|
||||
* Perform a request with the given {@link RequestInput} container.
|
||||
*/
|
||||
GraphQLTester.ResponseSpec execute(RequestInput input);
|
||||
|
||||
@@ -153,11 +153,11 @@ class DefaultGraphQLTester implements GraphQLTester {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubscriptionSpec executeSubscription(RequestInput queryInput) {
|
||||
public SubscriptionSpec executeSubscription(RequestInput requestInput) {
|
||||
FluxExchangeResult<TestExecutionResult> exchangeResult = this.client.post()
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.accept(MediaType.TEXT_EVENT_STREAM)
|
||||
.bodyValue(queryInput)
|
||||
.bodyValue(requestInput)
|
||||
.exchange()
|
||||
.expectStatus().isOk()
|
||||
.expectHeader().contentType(MediaType.TEXT_EVENT_STREAM)
|
||||
@@ -224,7 +224,7 @@ class DefaultGraphQLTester implements GraphQLTester {
|
||||
assertion.run();
|
||||
}
|
||||
catch (AssertionError ex) {
|
||||
throw new AssertionError(ex.getMessage() + "\nQuery: " + input, ex);
|
||||
throw new AssertionError(ex.getMessage() + "\nRequest: " + input, ex);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -232,9 +232,9 @@ class DefaultGraphQLTester implements GraphQLTester {
|
||||
|
||||
|
||||
/**
|
||||
* {@link QuerySpec} that collects the query, operationName, and variables.
|
||||
* {@link RequestSpec} that collects the query, operationName, and variables.
|
||||
*/
|
||||
private class DefaultQuerySpec implements QuerySpec {
|
||||
private class DefaultRequestSpec implements RequestSpec {
|
||||
|
||||
private final String query;
|
||||
|
||||
@@ -243,25 +243,25 @@ class DefaultGraphQLTester implements GraphQLTester {
|
||||
|
||||
private final Map<String, Object> variables = new LinkedHashMap<>();
|
||||
|
||||
private DefaultQuerySpec(String query) {
|
||||
private DefaultRequestSpec(String query) {
|
||||
Assert.notNull(query, "`query` is required");
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuerySpec operationName(@Nullable String name) {
|
||||
public RequestSpec operationName(@Nullable String name) {
|
||||
this.operationName = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuerySpec variable(String name, Object value) {
|
||||
public RequestSpec variable(String name, Object value) {
|
||||
this.variables.put(name, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuerySpec variables(Consumer<Map<String, Object>> variablesConsumer) {
|
||||
public RequestSpec variables(Consumer<Map<String, Object>> variablesConsumer) {
|
||||
variablesConsumer.accept(this.variables);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -92,12 +92,13 @@ import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
public interface GraphQLTester {
|
||||
|
||||
/**
|
||||
* Prepare to perform a GraphQL request with the given query.
|
||||
* @param query the query to send
|
||||
* Prepare to perform a GraphQL request with the given operation which may
|
||||
* be a query, mutation, or a subscription.
|
||||
* @param query the operation to be performed
|
||||
* @return spec for response assertions
|
||||
* @throws AssertionError if the response status is not 200 (OK)
|
||||
*/
|
||||
QuerySpec query(String query);
|
||||
RequestSpec query(String query);
|
||||
|
||||
|
||||
/**
|
||||
@@ -157,24 +158,24 @@ public interface GraphQLTester {
|
||||
|
||||
|
||||
/**
|
||||
* Declare options to gather input for a GraphQL query and execute it.
|
||||
* Declare options to gather input for a GraphQL request and execute it.
|
||||
*/
|
||||
interface QuerySpec extends ExecuteSpec {
|
||||
interface RequestSpec extends ExecuteSpec {
|
||||
|
||||
/**
|
||||
* Set the operation name.
|
||||
*/
|
||||
QuerySpec operationName(@Nullable String name);
|
||||
RequestSpec operationName(@Nullable String name);
|
||||
|
||||
/**
|
||||
* Add a variable.
|
||||
*/
|
||||
QuerySpec variable(String name, Object value);
|
||||
RequestSpec variable(String name, Object value);
|
||||
|
||||
/**
|
||||
* Modify variables by accessing the underlying map.
|
||||
*/
|
||||
QuerySpec variables(Consumer<Map<String, Object>> variablesConsumer);
|
||||
RequestSpec variables(Consumer<Map<String, Object>> variablesConsumer);
|
||||
}
|
||||
|
||||
|
||||
@@ -185,8 +186,8 @@ public interface GraphQLTester {
|
||||
|
||||
/**
|
||||
* Switch to a path under the "data" section of the GraphQL response.
|
||||
* The path can be a query root type name, e.g. "project", or a nested
|
||||
* path such as "project.name", or any
|
||||
* The path can be an operation root type name, e.g. "project", or a
|
||||
* nested path such as "project.name", or any
|
||||
* <a href="https://github.com/jayway/JsonPath">JsonPath</a>.
|
||||
*
|
||||
* @param path the path to switch to
|
||||
|
||||
Reference in New Issue
Block a user