0

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 :)

1 Answer 1

1

The problem seems to be that your ack method returns void which gets mapped to boolean, for the lack of a better option. As boolean is a simple scalar, you can not select anything from it, and you're trying to select an id in the query.

If you'd change your ack method to return the saved List<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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.