Skip to content

Commit

Permalink
Add Gen 2 SDL docs (#7793)
Browse files Browse the repository at this point in the history
* add gen 2 SDL docs

* Update src/pages/[platform]/build-a-backend/data/data-modeling/index.mdx

Co-authored-by: josef <josef.aidt@gmail.com>

* Update src/pages/[platform]/build-a-backend/data/data-modeling/index.mdx

Co-authored-by: josef <josef.aidt@gmail.com>

* move support callout to migration page

* update doc to state ddb-backed sources only

* made updates to the sdl explanation

---------

Co-authored-by: josef <josef.aidt@gmail.com>
Co-authored-by: Nikhil Swaminathan <nikhil@live.ca>
  • Loading branch information
3 people authored Jul 12, 2024
1 parent 96f9f1f commit c454d67
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
32 changes: 32 additions & 0 deletions src/pages/[platform]/build-a-backend/data/data-modeling/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export function getStaticProps(context) {
};
}

## Data modeling capabilities

Every data model is defined as part of a data schema (`a.schema()`). You can enhance your data model with various fields, customize their identifiers, apply authorization rules, or model relationships. Every data model (`a.model()`) automatically provides create, read, update, and delete API operations as well as real-time subscription events. Below is a quick tour of the many functionalities you can add to your data model:

Expand Down Expand Up @@ -84,3 +85,34 @@ export const data = defineData({
```

<Overview childPageNodes={props.childPageNodes} />

## Gen 1 schema support

If you are coming from Gen 1, you can continue to use the GraphQL Schema Definition Language (SDL) for defining your schema. However, we strongly recommend you use the TypeScript-first schema builder experience in your project as it provides type safety and is the recommended way of working with Amplify going forward.

<Callout>

**Note:** Some features available in Gen 1 GraphQL SDL are not available in Gen 2. See the [feature matrix](/[platform]/start/migrate-to-gen2/#gen-1-vs-gen-2-feature-matrix) for features supported in Gen 2.

</Callout>

```ts title="amplify/data/resource.ts"
import { defineData } from '@aws-amplify/backend';

const schema = /* GraphQL */`
type Todo @model @auth(rules: [{ allow: owner }]) {
content: String
isDone: Boolean
}
`;

export const data = defineData({
schema,
authorizationModes: {
defaultAuthorizationMode: "apiKey",
apiKeyAuthorizationMode: {
expiresInDays: 30,
},
},
});
```
12 changes: 7 additions & 5 deletions src/pages/[platform]/start/migrate-to-gen2/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The tables below present a feature matrix for Gen 1 customers who are considerin
### Auth

| Feature | Gen 1 | Gen 2 |
|---|---|---|
|---|---|---|
| Configure username | Yes | Yes with CDK |
| Configure email | Yes | Yes |
| Configure phone number | Yes | Yes |
Expand Down Expand Up @@ -92,7 +92,7 @@ The tables below present a feature matrix for Gen 1 customers who are considerin
| hasOne | Yes | Yes |
| hasMany | Yes | Yes |
| belongsTo | Yes | Yes |
| manyToMany | Yes | Yes |
| manyToMany | Yes | No |
| default | Yes | Yes |
| **auth - model level** | | |
| auth - public - apiKey | Yes | Yes |
Expand Down Expand Up @@ -143,6 +143,8 @@ The tables below present a feature matrix for Gen 1 customers who are considerin
| Custom GraphQL Transformer plugins | Yes | No |
| MySQL and PostgreSQL support | No | Yes |
| In-IDE end-to-end type safety | No | Yes |
| @hasOne, @hasMany, and @belongsTo on required fields | Yes | No |
| fields argument on @hasOne, @hasMany, and @belongsTo | Yes | No |

### Storage

Expand Down Expand Up @@ -200,7 +202,7 @@ The tables below present a feature matrix for Gen 1 customers who are considerin
<InlineFilter filters={['android', 'swift']}>

| Feature | Gen 1 | Gen 2 |
|---|---|---|
|---|---|---|
| REST API| Yes| No
| Analytics| Yes| Yes with custom CDK
| Geo| Yes| Yes with custom CDK
Expand All @@ -212,7 +214,7 @@ The tables below present a feature matrix for Gen 1 customers who are considerin
<InlineFilter filters={['flutter']}>

| Feature | Gen 1 | Gen 2 |
|---|---|---|
|---|---|---|
| REST API| Yes| Yes with custom CDK
| Analytics| Yes| Yes with custom CDK
| Geo| No| No
Expand All @@ -224,7 +226,7 @@ The tables below present a feature matrix for Gen 1 customers who are considerin
<InlineFilter filters={['angular','javascript','nextjs','react','react-native','vue']}>

| Feature | Gen 1 | Gen 2 |
|---|---|---|
|---|---|---|
| REST API| Yes| Yes with custom CDK
| Analytics| Yes| Yes with custom CDK
| Geo| Yes| Yes with custom CDK
Expand Down

0 comments on commit c454d67

Please sign in to comment.