-
-
Save koingdev/aafc4791af5bd9c0ae6f399a90a15e73 to your computer and use it in GitHub Desktop.
Test Amplify Schema
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Privacy { | |
PRIVATE | |
PUBLIC | |
} | |
type User @model { | |
id: String! # Cognito username | |
uuid: String! # Cognito UUID | |
displayName: String! | |
journals: [Journal] @connection(name: "UserJournals", sortField: "createdAt") # HAS MANY JOURNALS | |
comments: [Comment] @connection(name: "UserComments", sortField: "createdAt") # HAS MANY COMMENTS | |
lovedJournals: [UserLovedJournal] @connection(name: "UserLovedJournals") # HAS MANY LOVED JOURNALS | |
lovedComments: [UserLovedComment] @connection(name: "UserLovedComments") # HAS MANY LOVED COMMENTS | |
createdAt: AWSDateTime | |
updatedAt: AWSDateTime | |
} | |
type UserLovedJournal @model(queries: null) { | |
id: ID! | |
journal: Journal @connection(name: "JournalLovedUsers") | |
user: User @connection(name: "UserLovedJournals") | |
} | |
type Journal @model { | |
id: ID! | |
privacy: Privacy! # PRIVATE or PUBLIC | |
draft: Boolean! | |
content: AWSJSON! | |
author: User @connection(name: "UserJournals") # BELONGS TO WHICH AUTHOR | |
lovedUsers: [UserLovedJournal] @connection(name: "JournalLovedUsers") # HAS MANY LOVED USERS | |
comments: [Comment] @connection(name: "JournalComments", sortField: "createdAt") # HAS MANY COMMENTS | |
createdAt: AWSDateTime | |
updatedAt: AWSDateTime | |
} | |
# COMMENT | |
type UserLovedComment @model(queries: null) { | |
id: ID! | |
comment: Comment @connection(name: "CommentLovedUsers") | |
user: User @connection(name: "UserLovedComments") | |
} | |
type Comment @model { | |
id: ID! | |
content: String! | |
author: User @connection(name: "UserComments") # BELONGS TO WHICH AUTHOR | |
journal: Journal @connection(name: "JournalComments") # BELONGS TO WHICH JOURNAL | |
lovedUsers: [UserLovedComment] @connection(name: "CommentLovedUsers") # HAS MANY LOVED USERS | |
createdAt: AWSDateTime | |
updatedAt: AWSDateTime | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mutation CreateUser { | |
createUser( | |
input: { | |
id: "koingdev" | |
displayName: "SSK" | |
uuid: "cognito-uuid0001" | |
} | |
) { | |
id | |
} | |
} | |
mutation CreateJournal { | |
createJournal( | |
input: { | |
id: "journal-0001" | |
journalAuthorId: "koingdev" | |
privacy: PRIVATE | |
draft: false | |
content: "{ \"value\" : \"My first journal\" }" | |
} | |
) { | |
id | |
content | |
} | |
} | |
mutation CreateComment { | |
createComment( | |
input: { | |
id: "cmt-0001" | |
commentAuthorId: "koingdev" | |
commentJournalId: "journal-0001" | |
content: "How are you ?" | |
} | |
) { | |
id | |
content | |
} | |
} | |
mutation UserLoveJournal { | |
createUserLovedJournal( | |
input: { | |
userLovedJournalUserId: "koingdev" | |
userLovedJournalJournalId: "journal-0001" | |
} | |
) { | |
id | |
} | |
} | |
mutation UserLoveComment { | |
createUserLovedComment( | |
input: { | |
userLovedCommentUserId: "koingdev" | |
userLovedCommentCommentId: "cmt-0001" | |
} | |
) { | |
id | |
} | |
} | |
query GetUserInfo { | |
getUser(id: "koingdev") { | |
id | |
uuid | |
journals { | |
items { | |
id | |
privacy | |
content | |
comments { | |
items { | |
id | |
content | |
} | |
} | |
} | |
} | |
lovedJournals { | |
items { | |
journal { | |
id | |
content | |
} | |
} | |
} | |
lovedComments { | |
items { | |
comment { | |
id | |
content | |
} | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"data": { | |
"getUser": { | |
"id": "koingdev", | |
"uuid": "cognito-uuid0001", | |
"journals": { | |
"items": [ | |
{ | |
"id": "journal-0001", | |
"privacy": "PRIVATE", | |
"content": "{\"value\":\"My first journal\"}", | |
"createdAt": "2019-08-01T17:10:53.911Z", | |
"comments": { | |
"items": [ | |
{ | |
"id": "cmt-0001", | |
"content": "How are you ?" | |
} | |
] | |
} | |
}, | |
{ | |
"id": "journal-0002", | |
"privacy": "PRIVATE", | |
"content": "{\"value\":\"My 2nd journal\"}", | |
"createdAt": "2019-08-01T17:11:31.578Z", | |
"comments": { | |
"items": [] | |
} | |
}, | |
{ | |
"id": "journal-0005", | |
"privacy": "PRIVATE", | |
"content": "{\"value\":\"Computer is magic\"}", | |
"createdAt": "2019-08-01T17:43:30.917Z", | |
"comments": { | |
"items": [] | |
} | |
}, | |
{ | |
"id": "journal-0003", | |
"privacy": "PRIVATE", | |
"content": "{\"value\":\"I am good\"}", | |
"createdAt": "2019-08-01T17:43:46.874Z", | |
"comments": { | |
"items": [] | |
} | |
} | |
] | |
}, | |
"lovedJournals": { | |
"items": [ | |
{ | |
"journal": { | |
"id": "journal-0001", | |
"content": "{\"value\":\"My first journal\"}" | |
} | |
} | |
] | |
}, | |
"lovedComments": { | |
"items": [ | |
{ | |
"comment": { | |
"id": "cmt-0001", | |
"content": "How are you ?" | |
} | |
} | |
] | |
} | |
} | |
} | |
} |
Thank you. Got a couple questions.
-
Added Notification here. Want to make sure this makes sense. https://gist.github.com/ohsik/1506c0530a6744cff158f8af408be731#file-1-schema-graphql
-
@auth is needed or not? as you can see from above GraphQL, I added
@auth(
rules: [
{ allow: owner },
{ allow: groups, groups: ["Admin"] }
]
)
in to Notification. Because I want to make sure that only login user has access to the data except for Admin. Does it need to keep the app secure or does't really matter?
- Added Notification here. Want to make sure this makes sense.
LGTM ^^
- @auth is needed or not? as you can see from above GraphQL, I added
I think that it is better to put @auth rule base on your requirement.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
User.journals is sorted by created date