【发布时间】:2021-11-14 11:33:42
【问题描述】:
由于最近的一些 AWS 限制,在 Appsync 上使用 GraphQL 订阅时,我不能再使用 MQTT over Websockets。 基于this link from AWS,我更改了我的Python代码库。
好像连接正确,但是订阅的时候出现如下错误:
{'message': "Cannot return null for non-nullable type: 'ID' within parent 'Command' (/onCommandCreated/commandId)"}
Command 对象的每个字段都会重复出现此错误。
这是架构:
type Command {
commandId: ID!
createdAt: AWSDateTime!
command: String!
arguments: [String]!
deviceId: ID!
status: Int!
}
type Mutation {
submitCommand(command: NewCommand!): Command
}
input NewCommand {
command: String!
arguments: [String]!
deviceId: ID!
}
type Subscription {
onCommandCreated(deviceId: ID!): Command
@aws_subscribe(mutations: ["submitCommand"])
}
schema {
mutation: Mutation
subscription: Subscription
}
这是我的订阅:
{
"query": """subscription onCommand($deviceId: ID!) {
onCommandCreated(deviceId: $deviceId) {
commandId
deviceId
command
arguments
status
}
}
""",
"variables": {"deviceId": <a device id>}
}
我完全不清楚的是,我在切换到纯 websockets 后开始遇到这个问题。
我已经比较了纯 websockets 和 MQTT 之间的 Cloudwatch 日志,但我没有发现任何相关差异,除了请求 ID 和计时日志。
哦,忘了说我用的是OIDC认证方式。
代码库可用here。 谢谢,
【问题讨论】:
标签: python websocket graphql aws-appsync