我使用 GraphQL-SPQR 库问题是“SubSelectionRequired 类型的验证错误:Timestamp 类型需要子选择”也许在查询中存在时间戳或实体格式的表达式
{"query":
"{findUserPointByUserId(userId:73){rowNum userAccountPointUserId totalPoint pointTypeDescription point userAccountCreatedDate} findUserAccountImgByUserId(userId:73){imageId,userId,presentImgNum}}"
}
错误
{
"errors": [
{
"message": "Validation error of type SubSelectionRequired: Sub selection required for type Timestamp of field userAccountCreatedDate",
"locations": [
{
"line": 1,
"column": 103
}
]
}
]
}
实体
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@Entity
@Table(name = "view_user_account_point", schema = "public", catalog = "corus")
public class ViewUserAccountPoint {
@Id
@Basic
@GraphQLQuery(name = "rowNum")
@Column(name = "row_num", nullable = true)
private Long rowNum;
@Basic
@Column(name = "user_account_point_userid", nullable = true)
@GraphQLQuery(name = "userAccountPointUserId")
private Integer userAccountPointUserId;
@Basic
@Column(name = "subject_id", nullable = true)
@GraphQLQuery(name = "subjectId")
private Integer subjectId;
@Basic
@Column(name = "point", nullable = true)
@GraphQLQuery(name = "point")
private Integer point;
@Basic
@Column(name = "user_account_point_typeid", nullable = true)
@GraphQLQuery(name = "userAccountPointTypeId")
private Integer userAccountPointTypeId;
@Basic
@Column(name = "date_created", nullable = true)
@GraphQLQuery(name = "userAccountCreatedDate")
private Timestamp userAccountCreatedDate;
服务
public List<ViewUserAccountPoint> findUserPointByUserId(@GraphQLArgument(name = "userId") Integer userId){
return viewUserAccountPointRepository.findByUserAccountPointUserIdOrderByUserAccountCreatedDateDesc(userId);
}
控制器
private final GraphQL graphQL;
public UserController(UserAccountService userAccountService) {
GraphQLSchema schema = new GraphQLSchemaGenerator()
.withResolverBuilders(
//Resolve by annotations
new AnnotatedResolverBuilder())
.withOperationsFromSingleton(userAccountService,UserAccountService.class)
.withValueMapperFactory(new JacksonValueMapperFactory())
.generate();
graphQL = GraphQL.newGraphQL(schema).build();
}
@PostMapping(value = "/graphql", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
public Map<String, Object> graphql(@RequestBody Map<String, String> request, HttpServletRequest raw) {
ExecutionResult executionResult = graphQL.execute(ExecutionInput.newExecutionInput()
.query(request.get("query"))
.operationName(request.get("operationName"))
.context(raw)
.build());
return executionResult.toSpecification();
}
我搜索了所有查询时间戳格式但是,我找不到我希望听到的解决方案。谢谢你