0
0
DynamoDBquery~10 mins

AppSync with DynamoDB (GraphQL) - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a GraphQL query that fetches all items from a DynamoDB table.

DynamoDB
query ListItems {
  listItems [1] {
    items {
      id
      name
    }
  }
}
Drag options to blanks, or click blank then click option'
A()
B{filter: {}}
C(limit: 10)
D(id: "123")
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting parentheses causes syntax errors.
Passing unnecessary arguments when none are required.
2fill in blank
medium

Complete the mutation to add a new item with id and name fields.

DynamoDB
mutation AddItem {
  createItem(input: [1]) {
    id
    name
  }
}
Drag options to blanks, or click blank then click option'
A"id: 1, name: Item1"
B{id: "1", name: "Item1"}
C[id, name]
Did, name
Attempts:
3 left
💡 Hint
Common Mistakes
Using strings instead of objects for input.
Using arrays or comma-separated values without braces.
3fill in blank
hard

Fix the error in the resolver mapping template to get an item by id.

DynamoDB
{
  "version": "2018-05-29",
  "operation": "[1]",
  "key": {
    "id": $util.dynamodb.toDynamoDBJson($ctx.args.id)
  }
}
Drag options to blanks, or click blank then click option'
APutItem
BScan
CQuery
DGetItem
Attempts:
3 left
💡 Hint
Common Mistakes
Using PutItem instead of GetItem causes wrong operation.
Using Query without specifying key conditions.
4fill in blank
hard

Fill both blanks to create a resolver that queries items with a filter expression.

DynamoDB
{
  "version": "2018-05-29",
  "operation": "[1]",
  "filter": {
    "expression": "[2]",
    "expressionValues": {
      ":val": $util.dynamodb.toDynamoDBJson($ctx.args.filterValue)
    }
  }
}
Drag options to blanks, or click blank then click option'
AScan
BQuery
Cid = :val
Dname = :val
Attempts:
3 left
💡 Hint
Common Mistakes
Using Query without key condition causes errors.
Incorrect filter expression syntax.
5fill in blank
hard

Fill all three blanks to define a mutation resolver that updates an item attribute.

DynamoDB
{
  "version": "2018-05-29",
  "operation": "[1]",
  "key": {
    "id": $util.dynamodb.toDynamoDBJson($ctx.args.id)
  },
  "update": {
    "expression": "set [2] = :val",
    "expressionValues": {
      ":val": $util.dynamodb.toDynamoDBJson($ctx.args.newValue)
    }
  },
  "condition": "[3]"
}
Drag options to blanks, or click blank then click option'
AUpdateItem
BattributeName
Cattribute_exists(id)
DPutItem
Attempts:
3 left
💡 Hint
Common Mistakes
Using PutItem overwrites the whole item.
Missing condition can cause errors if item does not exist.