title: AppSync query resolver: are expressionNames and expressionValues necessary?
body: <p><a href="https://docs.aws.amazon.com/appsync/latest/devguide/resolver-mapping-template-reference-dynamodb.html#aws-appsync-resolver-mapping-template-reference-dynamodb-query" rel="nofollow noreferrer">https://docs.aws.amazon.com/appsync/latest/devguide/resolver-mapping-template-reference-dynamodb.html#aws-appsync-resolver-mapping-template-reference-dynamodb-query</a></p>
  
  <p>AppSync doc says that <code>expressionNames</code> and <code>expressionValues</code> are optional fields, but they are always populated by code generation. First question, should they be included as a best practice when working with DynamoDB? If so, why?</p>
  
  <p><strong>AppSync resolver for a query on the partition key:</strong></p>
  
  <pre><code>{
      "version": "2017-02-28",
      "operation": "Query",
      "query": {
          "expression": "#partitionKey = :partitionKey",
          "expressionNames": {
              "#partitionKey": "partitionKey"
          },
          "expressionValues": {
              ":partitionKey": {
                  "S": "${ctx.args.partitionKey}"
              }
          }
      }
  }
  </code></pre>
  
  <p>Second question, what exactly is the layman translation of the <code>expression</code> field here in the code above? What exactly is that statement telling DynamoDB to do? What is the use of the <code>#</code> in <code>"expression": "#partitionKey = :partitionKey"</code> and are the expression names and values just formatting safeguards?</p>