Due to some recent AWS restrictions, I can not use MQTT over Websockets any more when using GraphQL subscriptions on Appsync. Based on this link from AWS, I changed my Python codebase.
It seems to connect correctly, but when subscribing, I receive the following error:
{'message': "Cannot return null for non-nullable type: 'ID' within parent 'Command' (/onCommandCreated/commandId)"}
This error is repeated for each field of the Command
object.
This is the schema:
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
}
And this is my subscription:
{
"query": """subscription onCommand($deviceId: ID!) {
onCommandCreated(deviceId: $deviceId) {
commandId
deviceId
command
arguments
status
}
}
""",
"variables": {"deviceId": <a device id>}
}
What is absolutely unclear to me is that I have started having this issue after switching to pure websockets.
I have compared the Cloudwatch logs between pure websockets and MQTT but I did not notice any relevant difference, except for request id and timing logs.
Oh, I forgot to mention that I am using OIDC authentication method.
The codebase is available here. Thanks,