core/schema.graphql
2021-07-29 20:26:15 +03:00

206 lines
4.0 KiB
GraphQL

scalar DateTime
################################### Inputs
input registerUserInput {
email: String!
username: String
password: String!
}
input MessageInput {
body: String!
replyTo: Int
}
input updateMessageInput {
id: Int!
body: String!
}
################################### Payloads
type signInPayload {
status: Boolean!
error: String
token: String
}
type ResultPayload {
status: Boolean!
error: String
}
type createMessagePayload {
status: Boolean!
error: String
message: Message
}
type createShoutPayload {
status: Boolean!
error: String
shout: Shout
}
################################### Mutation
type Mutation {
# message
createMessage(input: MessageInput!): createMessagePayload!
updateMessage(input: updateMessageInput!): createMessagePayload!
deleteMessage(messageId: Int!): ResultPayload!
# auth
confirmEmail(token: String!): Token!
invalidateAllTokens: Boolean!
invalidateTokenById(id: Int!): Boolean!
requestEmailConfirmation: User!
requestPasswordReset(email: String!): Boolean!
resetPassword(password: String!, token: String!): Token!
registerUser(input: registerUserInput!): User!
# shout
createShout(): Shout!
deleteShout(shoutId: Int!): Boolean!
rateShout(value: Int!): Boolean!
# profile
rateUser(value: Int!): Boolean!
updateOnlineStatus: Boolean!
updateUsername(username: String!): User!
}
################################### Query
type Query {
# auth / user
signIn(email: String!, password: String!): signInPayload!
signOut: ResultPayload!
getCurrentUser: User!
isEmailFree(email: String!): Boolean!
getOnline: [User!]!
getUserById(id: Int!): User!
getUserRating(shout: Int): Int!
# messages
getMessages(count: Int = 100, page: Int = 1): [Message!]!
# shouts
getShoutRating(shout: Int): Int!
shoutsByAuthor(author: Int): [Shout]!
shoutsByReplyTo(shout: Int): [Shout]!
shoutsByTags(tags: [String]): [Shout]!
shoutsByTime(time: DateTime): [Shout]!
topAuthors: [User]!
topShouts: [Shout]!
}
############################################ Subscription
type Subscription {
messageCreated: Message!
messageUpdated: Message!
messageDeleted: Message!
onlineUpdated: [User!]!
shoutUpdated: Shout!
userUpdated: User!
}
############################################ Entities
type Role {
id: Int!
name: String!
org: String!
level: Int! # 1-8
desc: String
}
type User {
createdAt: DateTime!
email: String
emailConfirmed: Boolean
id: Int!
muted: Boolean
rating: Int
roles: [Role!]!
updatedAt: DateTime!
username: String
userpic: String
userpicId: String
wasOnlineAt: DateTime
}
type Message {
author: Int!
body: String!
createdAt: DateTime!
id: Int!
replyTo: Int
updatedAt: DateTime!
visibleForUsers: [Int]!
}
# is publication
type Shout {
id: Int!
org: String!
slug: String!
author: Int!
body: String!
createdAt: DateTime!
updatedAt: DateTime!
deletedAt: DateTime
deletedBy: Int
rating: Int
published: DateTime # if there is no published field - it is not published
replyTo: Int # another shout
tags: [String] # actual values
topics: [String] # topic-slugs
title: String
versionOf: Int
visibleForRoles: [String] # role ids are strings
visibleForUsers: [Int]
}
type Topic {
slug: String! # ID
createdBy: Int! # User
createdAt: DateTime!
value: String
parents: [String] # NOTE: topic can have parent topics
children: [String] # and children
}
# TODO: resolvers to add/remove topics from publication
type Proposal {
body: String!
shout: Int!
range: String # full / 0:2340
author: Int!
createdAt: DateTime!
}
type Token {
createdAt: DateTime!
expiresAt: DateTime
id: Int!
ownerId: Int!
usedAt: DateTime
value: String!
}
type Like {
author: Int!
id: Int!
value: Int!
shout: Int
user: Int
}