Skip to content

Commit

Permalink
add gen 2 SDL docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilch committed Jul 1, 2024
1 parent d662eec commit 46f89e4
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 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 @@ -83,4 +83,38 @@ export const data = defineData({
});
```

GraphQL Schema Definition Language (SDL) may also be used to define your schema.
Doing so will not result in the same level of type safety offered by the data schema builder.
The data schema builder is the recommened method for defining your schema.

<Callout>

**Note:** Some features available in Gen 1 GraphQL SDL are not available in Gen 2.

* Use of `@manyToMany`.
* Use of `fields` argument on `@hasOne`, `@hasMany`, and `@belongsTo`.
* Use of `@hasOne`, `@hasMany`, and `@belongsTo` on required fields.

</Callout>

```ts
import { defineData } from '@aws-amplify/backend';

const schema = `
type Todo @model @auth({ allow: public }) {
content: String
isDone: Boolean
}
`;
export const data = defineData({
schema,
authorizationModes: {
defaultAuthorizationMode: "apiKey",
apiKeyAuthorizationMode: {
expiresInDays: 30,
},
},
});
```

<Overview childPageNodes={props.childPageNodes} />

0 comments on commit 46f89e4

Please sign in to comment.