Make id mandatory for RequestInput

This commit is a follow up of 2e4158c and makes the following changes:

* the id is now a mandatory attribute for `WebInput` and `RequestInput`
* a consistent IdGenerator strategy is configured for all requests

Closes gh-183
This commit is contained in:
Brian Clozel
2021-11-25 12:30:56 +01:00
parent 9ce4b6801e
commit cfd0403008
13 changed files with 67 additions and 39 deletions

View File

@@ -21,7 +21,9 @@ import java.util.Map;
import org.springframework.graphql.RequestInput;
import org.springframework.lang.Nullable;
import org.springframework.util.AlternativeJdkIdGenerator;
import org.springframework.util.Assert;
import org.springframework.util.IdGenerator;
/**
* Base class support for implementations of
@@ -32,6 +34,8 @@ import org.springframework.util.Assert;
*/
class GraphQlTesterRequestSpecSupport {
private static final IdGenerator idGenerator = new AlternativeJdkIdGenerator();
private final String query;
@Nullable
@@ -66,7 +70,7 @@ class GraphQlTesterRequestSpecSupport {
}
protected RequestInput createRequestInput() {
return new RequestInput(this.query, this.operationName, this.variables, this.locale, null);
return new RequestInput(this.query, this.operationName, this.variables, this.locale, idGenerator.generateId().toString());
}
}