Name:
interface
Value:
Extend your Amplify Gen 2 app with AWS Blocks — self-contained backend capabilities you compose into your existing backend.

Page updated Apr 29, 2024

NewDeploy web apps with Git or your AI coding agent using the latest AWS Amplify. Add managed databases and authentication as you grow. Explore the documentation.
Maintenance ModeYou are viewing Amplify Gen 1 documentation. Amplify Gen 1 has entered maintenance mode and will reach end of life on May 1, 2027. For existing Gen 1 projects, a migration guide and tooling are available to help you upgrade.

Directives reference

These docs cover Amplify Gen 1. For new web apps, we recommend the latest AWS Amplify, with a simplified CLI and native integrations for databases, storage, and AI models. Get started with the latest AWS Amplify.

The Amplify CLI provides GraphQL directives to enhance your schema with additional capabilities such as custom indexes, authorization rules, function triggers, and more.

DirectiveDescription
@modelDefines top level object types in your API that are backed by Amazon DynamoDB
@primaryKeyConfigures custom primary key for @model types
@indexConfigures custom secondary index structures for @model types
@authDefines authorization rules for your @model types and fields
@hasOneCreate a one-directional one-to-one relationship between two models. For example, a Project "has one" Team. This allows you to query the team from the project record
@hasManyCreate a one-directional one-to-many relationship between two models. For example, a Post has many comments. This allows you to query all the comments from the post record
@belongsToUse a "belongs to" relationship to make a "has one" or "has many" relationship bi-directional. For example, a Project has one Team and a Team belongs to a Project. This allows you to query the team from the project record and vice versa
@manyToManyConfigures a "join table" between two models to facilitate a many-to-many relationship. For example, a Blog has many Tags and a Tag has many Blogs
@functionConfigures a Lambda function resolvers for a field
@httpConfigures an HTTP resolver for a field
@predictionsQueries an orchestration of AI/ML services such as Amazon Rekognition, Amazon Translate, and/or Amazon Polly
@searchableMakes your data searchable by streaming it to Amazon OpenSearch
@mapsToOnce a table contains production data that cannot be deleted, @mapsTo can be used to specify the original name