java - 错误:使用 Graphql 在 Spring Boot 中不可为空的类型是“ID”
问题描述
我刚刚设计了一个使用Graphql的Spring Boot示例。
我尝试通过id更新部门,但在id部分出现错误。
这是我的错误消息,如下所示。
The field at path '/updateDepartment/hospital/id' was declared as a non null type, but the code involved in retrieving data has wrongly returned a null value. The graphql specification requires that the parent field be set to null, or if that is non nullable that it bubble up null to its parent and so on. The non-nullable type is 'ID' within parent type 'Hospital'
这是我的突变和查询变量片段,如下所示。
mutation updateDepartment($departmentInput: DepartmentInput!) {
updateDepartment(id: 10,department: $departmentInput){
name
hospital{
id
}
}
}
{
"departmentInput": {
"name": "Department 10 Update",
"hospitalId": 3
}
}
这是我的项目链接:项目链接
我该如何解决这个错误?
解决方案
这是我的解决方案
突变
mutation updateDepartment($departmentInput: DepartmentInput!) {
updateDepartment(id: 10,department: $departmentInput){
name
}
}
查询变量
{
"departmentInput": {
"name": "Department 10 Update",
"hospitalId": 3
}
}
推荐阅读
- css - 如何将两个文本精确地向左对齐
- sql - SQL选择按时间增长排序的记录
- azure-devops - DevOps YAML 构建管道多存储库触发器分支未由 Release Pipeline 识别,用于持续部署触发器或工件过滤器
- c# - 如何对 DefaultAzureCredential 方法进行单元测试
- magento2 - Magento:如何按图像角色显示产品图像
- algorithm - 关于 DFS 的说法,是真的吗?
- python - 创建一个我需要清理的烂摊子,同时尝试解决 Macbook Pro M1 和 Tensorflow 库之间的冲突
- r - R. 数据表。如何区分两个不同data.table的同名列?
- r - R公式:将所有变量包装在转换中
- javascript - 更新数据的 D3.js 条形图问题