【问题标题】:graphql appsync query with boolean filter带有布尔过滤器的graphql appsync查询
【发布时间】:2019-07-26 16:59:18
【问题描述】:

我需要查询所有未完成的项目,其中完成后项目将获得状态更改 (Completed) 以及布尔值 isComplete==true

我正在通过 AWS Appsync 测试查询,然后再将它们硬编码到我的应用程序中,但这似乎并不有效。我想要isComplete==falseisComplete==null 的所有项目:布尔逻辑不适用于下面的input1 变量(0 个结果)。

{"__typename":{"S":"Project"},"addressLine1":{"S":"321 Faith Cir"},"city":{"S":"Perris"},"createdAt":{"S":"2019-03-05T01:01:39.513Z"},"currentOwner":{"S":"pgres52"},"dateRequired":{"S":"2019-03-13-07:00"},"id":{"S":"89a5-42ef7efef8fb"},"status":{"S":"Created"},"statusLastChangedAt":{"S":"2019-03-05T01:01:39.513Z"}}

{
  "input1":{
    "isComplete": {
      "ne": true
    }
  }
}

query listNonCompleteProjects($input1: ModelProjectFilterInput) {
  listProjects(filter: $input1, limit: 20) {
    items {
      id
      currentOwner
      addressLine1
      city
      dateRequired
      isComplete
      statusLastChangedAt
    }
    nextToken
  }
}```

【问题讨论】:

  • 您是在使用 AWS Amplify 代码生成还是您自己编写解析器?
  • 嗨 @Aaron_H,我使用了 Amplify 代码生成

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


【解决方案1】:

解决了!部分帮助了这篇文章:Prisma.io: How do I filter items with certain fields being null?

我能够使用附加参数status(字符串)使其工作:

query listNonCompleteProjects($input1: ModelProjectFilterInput) {
  listProjects(filter: $input1, limit: 20) {
    items {
      ...
    }
  }
}
  "input1":{
    "and": [
      {"status": {"notContains": "Complete"}},
      {"isComplete": {
        "ne": true
      }}
    ]
  },

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-17
    • 1970-01-01
    • 2019-05-25
    • 2021-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多