0

Using AWS AppSync, Graphql and DynamoDB

The following query is causing me an issue.

eventId is an optional field. When running the below query, records with the optional eventId field trigger an error. I would expect eventId to be null, if the resolver could not execute.. However the below message is triggered.

How would this be resolved?

query listTickets {
  listTickets {
    items {
      id,
      eventId {
       id,
      }
    }
  }
}

"message": "The provided key element does not match the schema (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException; Request ID: FTFDINCA42EALGI59I2VGH07G7VV4KQNSO5AEMVJF66Q9ASUAAJG)"

{
    "version": "2017-02-28",
    "operation": "GetItem",
    "key": {
        "id": $util.dynamodb.toDynamoDBJson($ctx.args.eventId),
    }
}
Lee
  • 5,816
  • 6
  • 45
  • 61
  • Does your table on which you are running the get item have a partition key called `id`? or is it a secondary index? – Karthik Aug 04 '18 at 07:43
  • Its all default, i've not added a key. It really does feel like its taking the null optional eventId and attempting to look up the id on it, triggering the schema error. – Lee Aug 04 '18 at 10:43
  • on which field is the above resolver attached? – Karthik Aug 04 '18 at 22:10
  • It's attached to EventId – Lee Aug 04 '18 at 22:21
  • So you are accessing $ctx.args.eventId, but eventId is not an argument. can you try $ctx.source.eventId ? – Karthik Aug 05 '18 at 04:20

0 Answers0