Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Gen 2 SDL docs #7793

Merged
merged 6 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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