typescript - React/Nextjs with GraphQL:将数据发布到后端(Spring)获取空对象
问题描述
我正在尝试使用 GraphQL Mutation 从我的前端(Nextjs)向我的后端(Java Spring)发送数据。我的问题是,当我从 GraphQL 操场调用 Mutation 时,在我的后端,我得到了一个具有空属性的对象。这是代码的一些贿赂:
我的突变定义:
export const SystemMutation = mutationType({
definition(t) {
t.field("addSystem",{
type: System,
args: {
input: arg({
type: SystemInput
})
},
async resolve(_parent, args, _context) {
return await createSystem(args.input);
}
})
}
})
这是调用后端存储数据的函数。
export const createSystem = async (system) => {
const res = await axios.post(`${server}/api/system/add`, system);
return res.data;
}
最后是应该接收数据的 Spring 控制器,当我在其中调试系统变量时,我得到了一个在所有属性中都具有空值的对象。
@PostMapping("/add")
public ResponseEntity<?> add(@Validated(SystemDto.Create.class) @ModelAttribute SystemDto system,
BindingResult result) {
return this.systemService.createSystem(system, result);
}
如果我在前端 console.log 参数“system”,我得到了我想要发送的数据。但是当我在后端发送它时,我得到了一个空对象。
我想念那里的东西吗?
谢谢你们的灯人。
解决方案
推荐阅读
- excel - Excel Weekday 函数,查找星期几
- keras - Keras Bi-LSTM CRF Python 到 R
- sql - Excel 和 SQL - Excel 文件之间的连接
- linux - 使用 Ansible 中的字符串查询搜索 Linux 进程 (PID)
- git - 在本地创建存储库并使用 ssh、git 授予访问权限
- python - 动态 Django 应用程序
- html - CSS clear:两者都不清除双方?
- javascript - 从 npm 的 python-shell 捕获错误
- r - “错误:应使用 `aes()` 或 `aes_()` 创建映射。”
- angular - 错误 TS1005: '(' 预期在具有新 Date() 的对象类型脚本中