Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7a3c6c5
cli flow for connecting api to existing database
chrisbonifacio Nov 10, 2023
0dbb785
add sql data types to cspell
chrisbonifacio Nov 10, 2023
a9d9f85
add link to rds proxy pricing page
chrisbonifacio Nov 10, 2023
cba3c3c
make schema.sql.graphql consistent
chrisbonifacio Nov 10, 2023
1459bac
change cyan mapping to skyblue for better readability
chrisbonifacio Nov 10, 2023
38cd4b2
adjust date type colors
chrisbonifacio Nov 10, 2023
08e1bb7
Add page to directory.mjs
chrisbonifacio Nov 14, 2023
f572551
update cdk with csv script and schema gen step
chrisbonifacio Nov 14, 2023
7fcb385
add terms to cspell
chrisbonifacio Nov 14, 2023
621ee93
add callout for time zone offsets
chrisbonifacio Nov 14, 2023
6bde20b
adjust header levels
chrisbonifacio Nov 14, 2023
9a9e7b5
remove redundant text
chrisbonifacio Nov 14, 2023
118d06f
add step to replace <database-name> in sql script
chrisbonifacio Nov 14, 2023
422b332
add step to replace <database-name> in sql script
chrisbonifacio Nov 14, 2023
d80162b
mention updating the path to the graphql file
chrisbonifacio Nov 14, 2023
7f0b182
Merge branch 'next-release/main' of github.com:aws-amplify/docs into …
chrisbonifacio Nov 14, 2023
1a83236
Merge branch 'next-release/main' of github.com:aws-amplify/docs into …
chrisbonifacio Nov 14, 2023
8297896
update links to point to platform/<v6-path>
chrisbonifacio Nov 14, 2023
49afe34
remove gen2/existing-projects page from directory.mjs
chrisbonifacio Nov 14, 2023
0218aa1
update MySQL csv script
chrisbonifacio Nov 15, 2023
9d707e7
update cdk construct api
chrisbonifacio Nov 15, 2023
11121ec
update sql script for postgres
chrisbonifacio Nov 15, 2023
684cf66
update sql scripts under iterative changes section
chrisbonifacio Nov 15, 2023
0ec4fc7
merge main into cbonif/connect-api-to-db
chrisbonifacio Nov 23, 2023
8f2e19a
refactor to CDK only workflow
chrisbonifacio Nov 24, 2023
5e22369
Add experimental note to iterative change section
chrisbonifacio Nov 24, 2023
48b9a9f
Merge branch 'main' of github.com:aws-amplify/docs into cbonif/connec…
chrisbonifacio Nov 24, 2023
ff6e457
applied edits for launch
Nov 27, 2023
a33e67e
reverted unintende file changes
Nov 27, 2023
58ef119
reverted unencessary file changes
Nov 27, 2023
b5cfe13
removed empty line hack
Nov 27, 2023
e243d2e
removed final model reference
Nov 27, 2023
cee25d8
removed the reference fo the word "model"
Nov 27, 2023
bf26898
Merge branch 'main' into cbonif/connect-api-to-db
renebrandel Nov 27, 2023
a075928
removed sandbox reference
Nov 27, 2023
1863c02
Merge branch 'cbonif/connect-api-to-db' of github.com:aws-amplify/doc…
Nov 27, 2023
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
Prev Previous commit
Next Next commit
removed final model reference
  • Loading branch information
Rene Brandel committed Nov 27, 2023
commit e243d2ed852f6d5add29cf55cd63ae05c31600d3
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ In the example below, a SQL statement is defined, accepting a `searchTerm` input
type Query {
searchPosts(searchTerm: String): [Post]
@sql(statement: "SELECT * FROM posts WHERE title LIKE :searchTerm;")
@auth(rules: [{ allow: public }])
}
```

Expand All @@ -220,6 +221,7 @@ First, update your GraphQL schema file to reference a SQL file name without the
type Query {
getPublishedPosts(start: AWSDate, end: AWSDate): [Post]
@sql(reference: "getPublishedPostsByRange")
@auth(rules: [{ allow: public }])
}
```

Expand Down Expand Up @@ -302,6 +304,7 @@ type Query {
@sql(
statement: "SELECT * FROM Post WHERE title LIKE CONCAT('%', :title, '%');"
)
@auth(rules: [{ allow: public }])
}
```

Expand All @@ -313,6 +316,7 @@ For reference, you define a GraphQL mutation by adding a new field under a `type
type Mutation {
publishPostById(id: ID!): AWSJSON
@sql(statement: "UPDATE posts SET published = :published WHERE id = :id;")
@auth(rules: [{ allow: public }])
}
```

Expand All @@ -325,6 +329,7 @@ If you want to return the result of the SQL statement, you can use `AWSJSON` as
```graphql
type Mutation {
publishPosts: AWSJSON @sql(statement: "UPDATE Post SET published = 1;")
@auth(rules: [{ allow: public }])
}
```

Expand Down Expand Up @@ -363,6 +368,7 @@ Call the stored procedure from the custom mutation:
type Mutation {
publishPostById(id: String!): [Post]
@sql(statement: "CALL publish_post(:id);")
@auth(rules: [{ allow: public }])
}
```

Expand All @@ -377,6 +383,7 @@ Example:
type Mutation {
publishPostById(id: String!): [Post]
@sql(statement: "UPDATE posts SET price = :id RETURNING *;")
@auth(rules: [{ allow: public }])
}
```

Expand All @@ -391,9 +398,9 @@ type Mutation {

## Apply authorization rules on the models

The `@auth` directive can be used to restrict access to data and operations by specifying authorization rules. It allows granular access control over the GraphQL API based on the user's identity and attributes.
The `@auth` directive can be used to restrict access to data and operations by specifying authorization rules. It allows granular access control over the GraphQL API based on the user's identity and attributes. You can for example, limit a query or mutation to only logged-in users via an `@auth(rules: [{ allow: private }])` rule or limit access to only users of the "Admin" group via an `@auth(rules: [{ allow: groups, groups: ["Admin"] }])` rule.

All model-level authorization rules are supported for Amplify GraphQL schemas generated from MySQL and PostgreSQL databases.
{/* All model-level authorization rules are supported for Amplify GraphQL schemas generated from MySQL and PostgreSQL databases.

<Callout warning>**Known limitation:** Field level auth rules are not supported.</Callout>

Expand All @@ -406,9 +413,9 @@ type Blog @model @refersTo(name: "blogs") @auth(rules: [{ allow: public }]) {
id: String! @primaryKey
title: String!
}
```
``` */}

In a real world scenario, you can instead define auth rules that only allow public users to read posts, and authenticated users the ability to update or delete their posts.
{/* In a real world scenario, you can instead define auth rules that only allow public users to read posts, and authenticated users the ability to update or delete their posts. */}

For more information on each rule please refer to our documentation on [Authorization rules](/[platform]/build-a-backend/graphqlapi/customize-authorization-rules/).

Expand Down