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
Changes from 1 commit
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 @@ -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 recommended method for defining your schema.
dpilch marked this conversation as resolved.
Show resolved Hide resolved

<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(rules: [{ allow: owner }]) {
content: String
isDone: Boolean
}
`;
export const data = defineData({
dpilch marked this conversation as resolved.
Show resolved Hide resolved
schema,
authorizationModes: {
defaultAuthorizationMode: "apiKey",
apiKeyAuthorizationMode: {
expiresInDays: 30,
},
},
});
```

<Overview childPageNodes={props.childPageNodes} />