Directives reference
The Amplify CLI provides GraphQL directives to enhance your schema with additional capabilities such as custom indexes, authorization rules, function triggers, and more.
| Directive | Description | 
|---|---|
| @model | Defines top level object types in your API that are backed by Amazon DynamoDB | 
| @primaryKey | Configures custom primary key for @model types | 
| @index | Configures custom secondary index structures for @model types | 
| @auth | Defines authorization rules for your @model types and fields | 
| @hasOne | Create 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 | 
| @hasMany | Create 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 | 
| @belongsTo | Use 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 | 
| @manyToMany | Configures 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 | 
| @function | Configures a Lambda function resolvers for a field | 
| @http | Configures an HTTP resolver for a field | 
| @predictions | Queries an orchestration of AI/ML services such as Amazon Rekognition, Amazon Translate, and/or Amazon Polly | 
| @searchable | Makes your data searchable by streaming it to Amazon OpenSearch | 
| @mapsTo | Once a table contains production data that cannot be deleted, @mapsTocan be used to specify the original name |