Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 25 additions & 23 deletions src/main/java/graphql/ExecutionInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@ public class ExecutionInput {
private final ExecutionId executionId;


public ExecutionInput(String query, String operationName, Object context, Object root, Map<String, Object> variables) {
this(query, operationName, context, root, variables, new DataLoaderRegistry(), null, null);
}

@Internal
private ExecutionInput(String query, String operationName, Object context, Object root, Map<String, Object> variables, DataLoaderRegistry dataLoaderRegistry, CacheControl cacheControl, ExecutionId executionId) {
this.query = query;
this.query = assertNotNull(query, "query can't be null");
this.operationName = operationName;
this.context = context;
this.root = root;
Expand Down Expand Up @@ -103,18 +99,19 @@ public ExecutionId getExecutionId() {
* the current values and allows you to transform it how you want.
*
* @param builderConsumer the consumer code that will be given a builder to transform
*
* @return a new ExecutionInput object based on calling build on that builder
*/
public ExecutionInput transform(Consumer<Builder> builderConsumer) {
Builder builder = new Builder()
.query(this.query)
.operationName(this.operationName)
.context(this.context)
.root(this.root)
.dataLoaderRegistry(this.dataLoaderRegistry)
.cacheControl(this.cacheControl)
.variables(this.variables)
.executionId(executionId);
.query(this.query)
.operationName(this.operationName)
.context(this.context)
.root(this.root)
.dataLoaderRegistry(this.dataLoaderRegistry)
.cacheControl(this.cacheControl)
.variables(this.variables)
.executionId(executionId);

builderConsumer.accept(builder);

Expand All @@ -125,14 +122,14 @@ public ExecutionInput transform(Consumer<Builder> builderConsumer) {
@Override
public String toString() {
return "ExecutionInput{" +
"query='" + query + '\'' +
", operationName='" + operationName + '\'' +
", context=" + context +
", root=" + root +
", variables=" + variables +
", dataLoaderRegistry=" + dataLoaderRegistry +
", executionId= " + executionId +
'}';
"query='" + query + '\'' +
", operationName='" + operationName + '\'' +
", context=" + context +
", root=" + root +
", variables=" + variables +
", dataLoaderRegistry=" + dataLoaderRegistry +
", executionId= " + executionId +
'}';
}

/**
Expand All @@ -146,6 +143,7 @@ public static Builder newExecutionInput() {
* Creates a new builder of ExecutionInput objects with the given query
*
* @param query the query to execute
*
* @return a new builder of ExecutionInput objects
*/
public static Builder newExecutionInput(String query) {
Expand All @@ -164,7 +162,7 @@ public static class Builder {
private ExecutionId executionId = null;

public Builder query(String query) {
this.query = query;
this.query = assertNotNull(query, "query can't be null");
return this;
}

Expand All @@ -175,7 +173,9 @@ public Builder operationName(String operationName) {

/**
* A default one will be assigned, but you can set your own.
*
* @param executionId an execution id object
*
* @return this builder
*/
public Builder executionId(ExecutionId executionId) {
Expand All @@ -187,6 +187,7 @@ public Builder executionId(ExecutionId executionId) {
* By default you will get a {@link GraphQLContext} object but you can set your own.
*
* @param context the context object to use
*
* @return this builder
*/
public Builder context(Object context) {
Expand All @@ -211,7 +212,7 @@ public Builder root(Object root) {
}

public Builder variables(Map<String, Object> variables) {
this.variables = variables;
this.variables = assertNotNull(variables, "variables map can't be null");
return this;
}

Expand All @@ -221,6 +222,7 @@ public Builder variables(Map<String, Object> variables) {
* instances as this will create unexpected results.
*
* @param dataLoaderRegistry a registry of {@link org.dataloader.DataLoader}s
*
* @return this builder
*/
public Builder dataLoaderRegistry(DataLoaderRegistry dataLoaderRegistry) {
Expand Down
Loading