-
-
Save ohsik/1506c0530a6744cff158f8af408be731 to your computer and use it in GitHub Desktop.
Test Amplify Schema
This file contains hidden or 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
type User @model { | |
id: String! # Cognito username | |
uuid: String! # Cognito UUID | |
displayName: String | |
profileImage: AWSURL | |
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 | |
notifications: [Notification] @connection(name: "UserNotifications", sortField: "createdAt") # HAS MANY NOTIFICATIONS | |
following: [Following] @connection(name: "UserFollowings", sortField: "createdAt") # HAS MANY FOLLOWINGS | |
follower: [Follower] @connection(name: "UserFollowers", sortField: "createdAt") # HAS MANY FOLLOWERS | |
createdAt: AWSDateTime | |
updatedAt: AWSDateTime | |
} | |
type Following @model(queries: null) { | |
id: ID! | |
user: User! @connection(name: "UserFollowings") | |
following: User! | |
createdAt: AWSDateTime | |
} | |
type Follower @model(queries: null) { | |
id: ID! | |
user: User! @connection(name: "UserFollowers") | |
follwer: User! | |
createdAt: AWSDateTime | |
} | |
type UserLovedJournal @model(queries: null) { | |
id: ID! | |
journal: Journal @connection(name: "JournalLovedUsers") | |
user: User @connection(name: "UserLovedJournals") | |
createdAt: AWSDateTime | |
} | |
type Journal | |
@model | |
@key(name: "privacy", fields: ["privacy", "createdAt"], queryField: "listPublicJournals") | |
@auth( | |
rules: [ | |
{ allow: owner }, | |
{ allow: groups, groups: ["Admin"] } | |
] | |
) { | |
id: ID! | |
privacy: String! # PRIVATE or PUBLIC | |
draft: Boolean! | |
content: String! | |
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 | |
} | |
type UserLovedComment @model(queries: null) { | |
id: ID! | |
comment: Comment @connection(name: "CommentLovedUsers") | |
user: User @connection(name: "UserLovedComments") | |
createdAt: AWSDateTime | |
} | |
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 | |
} | |
type Notification | |
@model | |
@auth( | |
rules: [ | |
{ allow: owner }, | |
{ allow: groups, groups: ["Admin"] } | |
] | |
) { | |
id: ID! | |
content: String! | |
category: String! | |
link: String! | |
read: Boolean! | |
user: User! @connection(name: "UserNotifications") | |
createdAt: AWSDateTime | |
} | |
#https://aws-amplify.github.io/docs/cli-toolchain/graphql#add-a-custom-resolver-that-targets-a-dynamodb-table-from-model | |
#https://aws-amplify.github.io/docs/cli-toolchain/graphql#add-a-custom-resolver-that-targets-an-aws-lambda-function | |
# type Query { | |
# getPublicJournalList(limit: Int, nextToken: String): [Journal] @function(name: "gnjamplifyGetPublicJournalList-${env}") | |
# } | |
type publicJournalsConnection { | |
items: [Journal] | |
nextToken: String | |
} | |
type Query { | |
getPublicJournals(privacy: String!, limit: Int, nextToken: String, sortDirection: DirectionEnum): publicJournalsConnection | |
getPublicJournalEntry(id: String!): Journal | |
} | |
enum DirectionEnum { | |
ASC | |
DESC | |
} |
This file contains hidden or 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 hidden or 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 ?" | |
} | |
} | |
] | |
} | |
} | |
} | |
} |
koingdev
commented
Aug 2, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment