Update request/response GraphQL classes
This commit decouples the HTTP layer from the expected request and response messages expected with GraphQL.
This commit is contained in:
@@ -1,46 +0,0 @@
|
||||
package org.springframework.graphql;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class GraphQLHttpRequest {
|
||||
private final String query;
|
||||
private final String operationName;
|
||||
private final Map<String, Object> variables;
|
||||
private final HttpHeaders httpHeaders;
|
||||
private final MultiValueMap<String, String> requestParams;
|
||||
|
||||
public GraphQLHttpRequest(String query,
|
||||
String operationName,
|
||||
Map<String, Object> variables,
|
||||
HttpHeaders httpHeaders,
|
||||
MultiValueMap<String, String> requestParams) {
|
||||
this.query = query;
|
||||
this.operationName = operationName;
|
||||
this.variables = variables;
|
||||
this.httpHeaders = httpHeaders;
|
||||
this.requestParams = requestParams;
|
||||
}
|
||||
|
||||
public String getQuery() {
|
||||
return query;
|
||||
}
|
||||
|
||||
public String getOperationName() {
|
||||
return operationName;
|
||||
}
|
||||
|
||||
public Map<String, Object> getVariables() {
|
||||
return variables;
|
||||
}
|
||||
|
||||
public HttpHeaders getHttpHeaders() {
|
||||
return httpHeaders;
|
||||
}
|
||||
|
||||
public MultiValueMap<String, String> getRequestParams() {
|
||||
return requestParams;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package org.springframework.graphql;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class GraphQLHttpResponse {
|
||||
|
||||
private final Object data;
|
||||
private final List<Map<String, Object>> errors;
|
||||
private final Map<String, Object> extensions;
|
||||
private final HttpHeaders httpHeaders;
|
||||
|
||||
public GraphQLHttpResponse(Object data,
|
||||
List<Map<String, Object>> errors,
|
||||
Map<String, Object> extensions,
|
||||
HttpHeaders httpHeaders) {
|
||||
this.data = data;
|
||||
this.errors = errors;
|
||||
this.extensions = extensions;
|
||||
this.httpHeaders = httpHeaders;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getErrors() {
|
||||
return errors;
|
||||
}
|
||||
|
||||
public Map<String, Object> getExtensions() {
|
||||
return extensions;
|
||||
}
|
||||
|
||||
public HttpHeaders getHttpHeaders() {
|
||||
return httpHeaders;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package org.springframework.graphql;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* @author Andreas Marek
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
public class GraphQLRequestBody {
|
||||
|
||||
private String query;
|
||||
|
||||
private String operationName;
|
||||
|
||||
private Map<String, Object> variables = Collections.emptyMap();
|
||||
|
||||
public GraphQLRequestBody(String query, String operationName, Map<String, Object> variables) {
|
||||
this.query = query;
|
||||
this.operationName = operationName;
|
||||
this.variables = variables;
|
||||
}
|
||||
|
||||
public GraphQLRequestBody() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getQuery() {
|
||||
return this.query;
|
||||
}
|
||||
|
||||
public void setQuery(String query) {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
public String getOperationName() {
|
||||
return this.operationName;
|
||||
}
|
||||
|
||||
public void setOperationName(String operationName) {
|
||||
this.operationName = operationName;
|
||||
}
|
||||
|
||||
public Map<String, Object> getVariables() {
|
||||
return this.variables;
|
||||
}
|
||||
|
||||
public void setVariables(Map<String, Object> variables) {
|
||||
this.variables = variables;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.springframework.graphql;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class GraphQLResponseBody<T> {
|
||||
|
||||
private T data;
|
||||
|
||||
private List<Map<String, Object>> errors = Collections.emptyList();
|
||||
|
||||
public GraphQLResponseBody() {
|
||||
}
|
||||
|
||||
public GraphQLResponseBody(T data) {
|
||||
this.data = data;
|
||||
this.errors = errors;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getErrors() {
|
||||
return this.errors;
|
||||
}
|
||||
|
||||
public void setErrors(List<Map<String, Object>> errors) {
|
||||
this.errors = errors;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user