Skip to content

Commit

Permalink
KOGITO-9721 - Use JSON scalar for process instance variables in Data …
Browse files Browse the repository at this point in the history
…Index GraphQL schema (#1830)
  • Loading branch information
cristianonicolai authored Aug 28, 2023
1 parent a9afd0a commit 5aad510
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -339,19 +339,19 @@ public void testProcessGatewayAPI() throws IOException {
testProcessGatewayAPIComments(taskId, pId2);
testProcessGatewayAPIAttachments(taskId, pId2);

String vars = given().spec(dataIndexSpec()).contentType(ContentType.JSON)
Map<String, Object> vars = given().spec(dataIndexSpec()).contentType(ContentType.JSON)
.body("{ \"query\" : \"{ ProcessInstances (where: { id: {equal: \\\"" + pId2 + "\\\"}}) { variables} }\"}")
.when().post("/graphql")
.then()
.statusCode(200).extract().path("data.ProcessInstances[0].variables");

if (vars != null) {
((Map<String, String>) vars.get("traveller")).put("firstName", "Anakin");
await()
.atMost(TIMEOUT)
.untilAsserted(() -> given().spec(dataIndexSpec()).contentType(ContentType.JSON)
.body("{ \"query\" : \"mutation{ ProcessInstanceUpdateVariables(id:\\\"" + pId2 + "\\\", variables:\\\"" +
vars.replace("Darth", "Anakin")
.replace("\"", "\\\\\\\"")
mapper.writeValueAsString(vars).replace("\"", "\\\\\\\"")
+ "\\\")}\"}")
.when().post("/graphql")
.then()
Expand All @@ -364,7 +364,7 @@ public void testProcessGatewayAPI() throws IOException {
.when().post("/graphql")
.then()
.statusCode(200)
.body("data.ProcessInstances[0].variables", containsString("Anakin")));
.body("data.ProcessInstances[0].variables.traveller.firstName", containsString("Anakin")));
}
given().spec(dataIndexSpec()).contentType(ContentType.JSON)
.body("{ \"query\" : \"mutation{ NodeInstanceTrigger(id:\\\"" + pId2 + "\\\", nodeId:\\\"_8B62D3CA-5D03-4B2B-832B-126469288BB4\\\")}\"}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
scalar DateTime
scalar BigDecimal
scalar Long
scalar JSON

schema {
query: Query
Expand All @@ -25,7 +26,7 @@ type ProcessInstance {
serviceUrl: String
nodes: [NodeInstance!]!
milestones: [Milestone!]
variables: String
variables: JSON
start: DateTime!
end: DateTime
parentProcessInstance: ProcessInstance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public GraphQLSchema createSchema() {
.scalar(getDateTimeScalarType())
.scalar(ExtendedScalars.GraphQLBigDecimal)
.scalar(ExtendedScalars.GraphQLLong)
.scalar(ExtendedScalars.Json)
.build();

SchemaGenerator schemaGenerator = new SchemaGenerator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public GraphQLSchema createSchema() {
.scalar(getDateTimeScalarType())
.scalar(ExtendedScalars.GraphQLBigDecimal)
.scalar(ExtendedScalars.GraphQLLong)
.scalar(ExtendedScalars.Json)
.build();

SchemaGenerator schemaGenerator = new SchemaGenerator();
Expand Down

0 comments on commit 5aad510

Please sign in to comment.