Skip to content

Commit c454d67

Browse files
Dane Pilcherjosefaidtswaminator
authored
Add Gen 2 SDL docs (#7793)
* 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>
1 parent 96f9f1f commit c454d67

File tree

2 files changed

+39
-5
lines changed
  • src/pages/[platform]

2 files changed

+39
-5
lines changed

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export function getStaticProps(context) {
3232
};
3333
}
3434

35+
## Data modeling capabilities
3536

3637
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:
3738

@@ -84,3 +85,34 @@ export const data = defineData({
8485
```
8586

8687
<Overview childPageNodes={props.childPageNodes} />
88+
89+
## Gen 1 schema support
90+
91+
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.
92+
93+
<Callout>
94+
95+
**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.
96+
97+
</Callout>
98+
99+
```ts title="amplify/data/resource.ts"
100+
import { defineData } from '@aws-amplify/backend';
101+
102+
const schema = /* GraphQL */`
103+
type Todo @model @auth(rules: [{ allow: owner }]) {
104+
content: String
105+
isDone: Boolean
106+
}
107+
`;
108+
109+
export const data = defineData({
110+
schema,
111+
authorizationModes: {
112+
defaultAuthorizationMode: "apiKey",
113+
apiKeyAuthorizationMode: {
114+
expiresInDays: 30,
115+
},
116+
},
117+
});
118+
```

src/pages/[platform]/start/migrate-to-gen2/index.mdx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ The tables below present a feature matrix for Gen 1 customers who are considerin
4141
### Auth
4242

4343
| Feature | Gen 1 | Gen 2 |
44-
|---|---|---|
44+
|---|---|---|
4545
| Configure username | Yes | Yes with CDK |
4646
| Configure email | Yes | Yes |
4747
| Configure phone number | Yes | Yes |
@@ -92,7 +92,7 @@ The tables below present a feature matrix for Gen 1 customers who are considerin
9292
| hasOne | Yes | Yes |
9393
| hasMany | Yes | Yes |
9494
| belongsTo | Yes | Yes |
95-
| manyToMany | Yes | Yes |
95+
| manyToMany | Yes | No |
9696
| default | Yes | Yes |
9797
| **auth - model level** | | |
9898
| auth - public - apiKey | Yes | Yes |
@@ -143,6 +143,8 @@ The tables below present a feature matrix for Gen 1 customers who are considerin
143143
| Custom GraphQL Transformer plugins | Yes | No |
144144
| MySQL and PostgreSQL support | No | Yes |
145145
| In-IDE end-to-end type safety | No | Yes |
146+
| @hasOne, @hasMany, and @belongsTo on required fields | Yes | No |
147+
| fields argument on @hasOne, @hasMany, and @belongsTo | Yes | No |
146148

147149
### Storage
148150

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

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

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

226228
| Feature | Gen 1 | Gen 2 |
227-
|---|---|---|
229+
|---|---|---|
228230
| REST API| Yes| Yes with custom CDK
229231
| Analytics| Yes| Yes with custom CDK
230232
| Geo| Yes| Yes with custom CDK

0 commit comments

Comments
 (0)