Changed tables and graphql schema

pull/1/head
Trivernis 5 years ago
parent 91188b1f58
commit b7d10454ab

@ -1,121 +1,100 @@
type Query { type Query {
getUser(userId: Id): User "returns the user object for a given user id"
getPost(postId: Id): Post getUser(userId: ID): User
getChat(chatId: Id): Chat "returns the post object for a post id"
getRequest(requestId: Id): Request getPost(postId: ID): Post
"returns the chat object for a chat id"
getChat(chatId: ID): ChatRoom
"returns the request object for a request id"
getRequest(requestId: ID): Request
"find a post by the posted date or content"
findPost(first: Int, offset: Int, text: String!, postedDate: String): [Post]
"find a user by user name or handle"
findUser(first: Int, offset: Int, name: String!, handle: String!): [User]
} }
type Mutation { type Mutation {
#_____Post_____ "Upvote/downvote a Post"
#"Upvote/downvote a Post" vote(postId: ID!, type: [VoteType!]!): Boolean
vote(postId: id!, type: [VoteType!]!): Bool "Report the post"
#"Report the post" report(postId: ID!): Boolean
report(postId: id!): Bool "lets you accept a request for a given request id"
#_____Request_____ acceptRequest(requestId: ID!): Boolean
#"if u accept a request" "send a message in a Chatroom"
acceptRequest(requestId: id!): bool sendMessage(chatId: ID!, content: String!): Boolean
#_____ChatRoom_____
#"send a assage in a Chatroom"
sendMassage(chatId: Id!, massage: String!): bool
} }
"represents a single user account"
type User { type User {
#"ProfilPicture of the User" "url for the Profile picture of the User"
profilPicture: String! profilePicture: String!
#"name from the User" "name of the User"
name: String! name: String!
#"unique name from the User" "unique identifier name from the User"
handle: String! handle: String!
#"Id from the User" "Id of the User"
userId: ID! id: ID!
#"Counted number of al Posts he posted" "the total number of posts the user posted"
numberOfPosts: int numberOfPosts: Int
#"show the posts of the User" "returns a given number of posts of a user"
getAllPosts(first: int, offset: int): [Post] getAllPosts(first: Int=10, offset: Int): [Post]
#"Date when he/she Created the account" "creation date of the user account"
JoinedDate: Date! joinedDate: String!
#"all chats for the mainsite(left)" "returns chats the user pinned"
pinnedChats: [Chats] pinnedChats: [ChatRoom]
#"all friends of the user" "returns all friends of the user"
friends: [User] friends: [User]
#"all request for groupChats/friends/events" "all request for groupChats/friends/events"
friends: [Request] requests: [Request]
} }
"represents a single user post"
type Post { type Post {
#"PicturePath" "returns the path to the posts picture if it has one"
picture: String picture: String
#"posted Text" "returns the text of the post"
text: String text: String
#"upvotes from Post" "upvotes of the Post"
upvotes: Int! upvotes: Int!
#"downvotes from Post" "downvotes of the Post"
downvotes: Int! downvotes: Int!
#"The AuthorID of the Post" "the user that is the author of the Post"
author: User! author: User!
#"Creationdate of the Post" "date the post was created"
creationDate: Date! creationDate: String!
#"Upvoteted/Downvoted the User already (NoVote(Null),Upvote,Downvote)" "returns the type of vote the user performed on the post"
alreadyVoted: [VoteType] alreadyVoted: VoteType
#"with tags u can find the post in a research" "returns the tags of the post"
tags: [String] tags: [String]
} }
type Search { "represents a request of any type"
#"u can find posts with a name(text) or posted time"
findPost(first: int, offset: int, text: String!, postedDate: Date): [Post]
#"u can find a User with his Name or handle"
findUser(first: int, offset: int, name: String!, handle: string!): [User]
}
type Request { type Request {
#"RequestId" "id of the request"
requestId: Id! id: ID!
#"RequestType" "type of the request"
requestType: [RequestType!]! requestType: RequestType!
} }
"represents a chatroom"
type ChatRoom { type ChatRoom {
#"Every User in the room" "the members of the chatroom"
members: [Users!] members: [User!]
#"Get the Chat" "return a specfic range of messages posted in the chat"
getMessages(first: int, offset: int): [String] getMessages(first: Int, offset: Int): [String]
#"chatId" "id of the chat"
chatId: Id! id: ID!
} }
"represents the type of vote performed on a post"
enum VoteType { enum VoteType {
UPDATE UPVOTE
DOWNVOTE DOWNVOTE
} }
"represents the type of request that the user has received"
enum RequestType { enum RequestType {
FRIENDREQUEST FRIENDREQUEST
GROUPINVITE GROUPINVITE
EVENTINVITE EVENTINVITE
} }
#type Event {
#}
#type Comment {
# #"CommentId"
# commentId: Id!
# #"text from the Comment"
# text: String
# #"PostId"
# postId: Id
# #"Upvotes of the comment"
# upvotes: int!
# #"Downvotes of the comment"
# downvotes: int!
# #"Upvoteted/Downvoted the User already (NoVote(Null),Upvote,Downvote)"
# alreadyVoted: [VoteType]
# #"Creationdate of the Post"
# creationDate: Date!
#Comment
# #"Upvote/downvote a Comment"
# vote(CommentId: id!, type: [VoteType!]!): Bool
# #"Report the Comment"
# report(CommentId: id!): Bool
#}

@ -1,23 +1,26 @@
CREATE TABLE IF NOT EXISTS users ( CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
name varchar(128) NOT NULL, name varchar(128) NOT NULL,
handle varchar(128) UNIQUE NOT NULL,
password varchar(1024) NOT NULL, password varchar(1024) NOT NULL,
email varchar(128) UNIQUE NOT NULL, email varchar(128) UNIQUE NOT NULL,
greenpoints INTEGER DEFAULT 0 greenpoints INTEGER DEFAULT 0,
joined_at TIMESTAMP DEFAULT now()
); );
CREATE TABLE IF NOT EXISTS feed_items ( CREATE TABLE IF NOT EXISTS posts (
id BIGSERIAL PRIMARY KEY, id BIGSERIAL PRIMARY KEY,
upvotes INTEGER DEFAULT 0, upvotes INTEGER DEFAULT 0,
downvotes INTEGER DEFAULT 0, downvotes INTEGER DEFAULT 0,
created_at TIMESTAMP DEFAULT now(), created_at TIMESTAMP DEFAULT now(),
content text, content text,
author SERIAL REFERENCES users (id) ON DELETE CASCADE author SERIAL REFERENCES users (id) ON DELETE CASCADE,
type varchar(16) NOT NULL
); );
CREATE TABLE IF NOT EXISTS votes ( CREATE TABLE IF NOT EXISTS votes (
user_id SERIAL REFERENCES users (id) ON DELETE CASCADE, user_id SERIAL REFERENCES users (id) ON DELETE CASCADE,
item_id BIGSERIAL REFERENCES feed_items (id) ON DELETE CASCADE item_id BIGSERIAL REFERENCES posts (id) ON DELETE CASCADE
); );
CREATE TABLE IF NOT EXISTS events ( CREATE TABLE IF NOT EXISTS events (
@ -47,3 +50,8 @@ CREATE TABLE IF NOT EXISTS chat_members (
chat BIGSERIAL REFERENCES chats (id) ON DELETE CASCADE, chat BIGSERIAL REFERENCES chats (id) ON DELETE CASCADE,
member SERIAL REFERENCES users (id) ON DELETE CASCADE member SERIAL REFERENCES users (id) ON DELETE CASCADE
); );
CREATE TABLE IF NOT EXISTS user_friends (
user_id SERIAL REFERENCES users (id) ON DELETE CASCADE,
friend_id SERIAL REFERENCES users (id) ON DELETE CASCADE
);

Loading…
Cancel
Save