模式 graphql 错误给出 'Cannot return null for non-nullable field Organisation.id' 为什么?
Schema graphql error gives 'Cannot return null for non-nullable field Organisation.id' why?
我在 Amplify with a simple Model 中有一个 graphql 模式。我收到错误消息“对于不可为 null 的字段 Organisation.id 不能 return null。”当我尝试获取有效 ID 时,为什么?
型号
type Organisation
@model
{
id: ID!
name: String!
}
查询:
const org = await API.graphql(graphqlOperation(getOrganisationQuery, { id: 'f18881fb-4cf3-42de-84b1-9396f932938d' }));
错误:
对于不可为 null 的字段 Organisation.id.
不能 return null
!
表示字段返回值不能为null
修复 1
去掉感叹号!
去掉错误
修复 2
确保该字段存在该值
我在 Amplify with a simple Model 中有一个 graphql 模式。我收到错误消息“对于不可为 null 的字段 Organisation.id 不能 return null。”当我尝试获取有效 ID 时,为什么?
型号
type Organisation
@model
{
id: ID!
name: String!
}
查询:
const org = await API.graphql(graphqlOperation(getOrganisationQuery, { id: 'f18881fb-4cf3-42de-84b1-9396f932938d' }));
错误: 对于不可为 null 的字段 Organisation.id.
不能 return null!
表示字段返回值不能为null
修复 1
去掉感叹号!
去掉错误
修复 2
确保该字段存在该值