0

我有一个要求,我必须接受对象列表。

突变类中的方法如下所示

@GraphQLMutation //1
    public void ack(@GraphQLInputField List<PingEntity> pingEntityList) { //2
        log.info("Handling ack calls.");        
        pingEntityRepository.savePingEntityList(pingEntityList);
    }

PingEntity 看起来像这样

@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;

}

我的查询看起来像这样

mutation ack {
  ack(pingEntityList: [{action: "KEEP-ALIVE2", message: "Keep alive message at regular intervals", timestamp: 1462747047}]) {
    id
  }
}

我得到这样的错误:

"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"
    }
  ]
}

我尝试给出不同的注释。我无法解决这个问题..在这个问题上需要帮助

提前致谢 :)

4

1 回答 1

2

问题似乎是您的ack方法返回void映射到boolean,因为缺乏更好的选择。作为boolean一个简单的标量,您不能从中选择任何内容,并且您正在尝试id在查询中选择一个。

如果你改变你的ack方法来返回 saved List<PingEntity>,你会得到你想要的行为。

@GraphQLInputField但是...更重要的是,您使用的是什么库,因为我在您的代码中看到的注释 ( )不是来自 graphql-java (因为 graphql-java 本身没有提供注释),也不是来自我认识的任何库。

它似乎来自一个非常古老且从未公开发布的 graphql-spqr 版本。如果确实如此,您绝对需要更新到最新版本,因为您似乎使用的版本充其量只是 alpha 质量。

于 2017-09-06T09:23:12.773 回答