【问题标题】:Schema graphql error gives 'Cannot return null for non-nullable field Organisation.id' why?Schema graphql 错误给出“不能为不可为空的字段 Organisation.id 返回 null”为什么?
【发布时间】:2021-05-21 16:50:11
【问题描述】:

我在 Amplify 中有一个带有简单模型的 graphql 架构。我收到错误“不能为不可为空的字段 Organisation.id 返回 null。”当我尝试获取有效 ID 时,为什么?

型号

type Organisation 
  @model
  {
    id: ID!
    name: String!
  }

查询:

const org = await API.graphql(graphqlOperation(getOrganisationQuery, { id: 'f18881fb-4cf3-42de-84b1-9396f932938d' }));

错误: 不能为不可为空的字段 Organisation.id 返回 null。

【问题讨论】:

    标签: amazon-web-services graphql amazon-dynamodb aws-amplify


    【解决方案1】:

    !表示该字段的返回值不能为空

    修复 1

    去掉感叹号!即可排除错误

    修复 2

    确保该字段的值存在

    【讨论】:

      猜你喜欢
      • 2019-05-28
      • 2019-10-25
      • 2021-03-18
      • 2019-07-08
      • 2021-10-07
      • 2023-03-28
      • 2021-08-18
      • 2021-11-27
      • 2021-10-24
      相关资源
      最近更新 更多