I have a requirement where i have to accept the list of objects.
The method in mutation class looks like this
@GraphQLMutation //1
public void ack(@GraphQLInputField List<PingEntity> pingEntityList) { //2
log.info("Handling ack calls.");
pingEntityRepository.savePingEntityList(pingEntityList);
}
PingEntity looks like this
@Data
//@Document(collection="pingdatastore")
@AllArgsConstructor
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class PingEntity {
private String id;
@JsonProperty("action")
private String action;
@JsonProperty("message")
private String message;
@JsonProperty("timestamp")
private Long timestamp;
@JsonProperty("transactionId")
private String transactionId;
@JsonProperty("type")
private Integer type;
private String imei;
}
my query looks like this
mutation ack {
ack(pingEntityList: [{action: "KEEP-ALIVE2", message: "Keep alive message at regular intervals", timestamp: 1462747047}]) {
id
}
}
I got the Error like this:
"data": null,
"errors": [
{
"validationErrorType": "SubSelectionNotAllowed",
"message": "Validation error of type SubSelectionNotAllowed: Sub selection not allowed on leaf type Boolean",
"locations": [
{
"line": 2,
"column": 3
}
],
"errorType": "ValidationError"
}
]
}
I tried giving different annotations. i am not able to solve this issue.. need help in this issue
Thanks in advance :)
The problem seems to be that your
ack
method returnsvoid
which gets mapped toboolean
, for the lack of a better option. Asboolean
is a simple scalar, you can not select anything from it, and you're trying to select anid
in the query.If you'd change your
ack
method to return the savedList<PingEntity>
, you'd get the behavior you wanted.But... more importantly, what library are you using, as the annotations I see (
@GraphQLInputField
) in your code are not from graphql-java (as graphql-java itself provides no annotations), nor from any of the libraries I recognize.It seems to be coming from a really old and never publically released version of graphql-spqr. If this is indeed the case, you absolutely need to update to the latest as the version you seem to be using was alpha quality at best.