Skip to content

Commit e5eedc7

Browse files
author
Dane Pilcher
committed
add gen 2 SDL docs
1 parent d662eec commit e5eedc7

File tree

1 file changed

+34
-0
lines changed
  • src/pages/[platform]/build-a-backend/data/data-modeling

1 file changed

+34
-0
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,38 @@ export const data = defineData({
8383
});
8484
```
8585

86+
GraphQL Schema Definition Language (SDL) may also be used to define your schema.
87+
Doing so will not result in the same level of type safety offered by the data schema builder.
88+
The data schema builder is the recommended method for defining your schema.
89+
90+
<Callout>
91+
92+
**Note:** Some features available in Gen 1 GraphQL SDL are not available in Gen 2.
93+
94+
* Use of `@manyToMany`.
95+
* Use of `fields` argument on `@hasOne`, `@hasMany`, and `@belongsTo`.
96+
* Use of `@hasOne`, `@hasMany`, and `@belongsTo` on required fields.
97+
98+
</Callout>
99+
100+
```ts
101+
import { defineData } from '@aws-amplify/backend';
102+
103+
const schema = `
104+
type Todo @model @auth(rules: [{ allow: owner }]) {
105+
content: String
106+
isDone: Boolean
107+
}
108+
`;
109+
export const data = defineData({
110+
schema,
111+
authorizationModes: {
112+
defaultAuthorizationMode: "apiKey",
113+
apiKeyAuthorizationMode: {
114+
expiresInDays: 30,
115+
},
116+
},
117+
});
118+
```
119+
86120
<Overview childPageNodes={props.childPageNodes} />

0 commit comments

Comments
 (0)