0

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,

fcracker79
  • 1,118
  • 13
  • 26

1 Answers1

0

In the end I removed the not-null requirements for the Command object.

As a result, the new Command object is the following:

type Command {
    commandId: ID
    createdAt: AWSDateTime
    command: String
    arguments: [String]
    deviceId: ID
    status: Int
}

This is not to be taken as a solution but a workaround.

Any more decent solutions are welcome.

fcracker79
  • 1,118
  • 13
  • 26