Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Projections

Focus mode
Projections - AWS AppSync GraphQL

When reading objects in DynamoDB using the GetItem, Scan, Query, BatchGetItem, and TransactGetItems operations, you can optionally specify a projection that identifies the attributes that you want. The projection property has the following structure, which is similar to filters:

type DynamoDBExpression = { expression: string; expressionNames?: { [key: string]: string} };

The fields are defined as follows:

expression

The projection expression, which is a string. To retrieve a single attribute, specify its name. For multiple attributes, the names must be comma-separated values. For more information on writing projection expressions, see the DynamoDB projection expressions documentation. This field is required.

expressionNames

The substitutions for expression attribute name placeholders in the form of key-value pairs. The key corresponds to a name placeholder used in the expression. The value must be a string that corresponds to the attribute name of the item in DynamoDB. This field is optional and should only be populated with substitutions for expression attribute name placeholders used in the expression. For more information about expressionNames, see the DynamoDB documentation.

Example 1

The following example is a projection section for a JavaScript function in which only the attributes author and id are returned from DynamoDB:

projection : { expression : "#author, id", expressionNames : { "#author" : "author" } }
Tip

You can access your GraphQL request selection set using selectionSetList. This field allows you to frame your projection expression dynamically according to your requirements.

Note

While using projection expressions with the Query and Scan operations, the value for select must be SPECIFIC_ATTRIBUTES. For more information, see the DynamoDB documentation.

On this page

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.