场景描述
用户在自定义接口提供给前端调用时
@Action(displayName = "注册", bindingType = ViewTypeEnum.CUSTOM)
public BaseResponse register(UserZhgl data) {
//...逻辑
return result;
}
import java.io.Serializable;
public class BaseResponse implements Serializable {
private String code;
private String msg;
public BaseResponse() {
}
public BaseResponse(String code, String msg) {
this.code = code;
this.msg = msg;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
gql执行时出现报错
{
"errors":[
{
"message":"Validation error of type SubSelectionNotAllowed: Sub selection not allowed on leaf type Object of field register @ 'zhglMutation/register'",
"locations":[
{
"line":3,
"column":3
}
],
"extensions":{
"classification":"ValidationError"
}
}
]
}
解决方案
1.返回对象不为空时,对象必须是模型,否则无法解析返回参数
2.前端调用GQL异常时,可以用Insomnia工具对GQL进行测试,根据错误提示对GQL进行修改和排查
3.GQL正常情况下,执行以后可根据后端日志进行错误排查
Oinone社区 作者:oinone原创文章,如若转载,请注明出处:https://doc.oinone.top/frontend/10.html
访问Oinone官网:https://www.oinone.top获取数式Oinone低代码应用平台体验