core/schema.graphql

339 lines
6.3 KiB
GraphQL
Raw Normal View History

2021-08-20 23:17:15 +00:00
scalar DateTime
################################### Payload
type Result {
2021-10-30 19:37:57 +00:00
error: String
2021-08-20 23:17:15 +00:00
}
type AuthResult {
2021-10-30 19:37:57 +00:00
error: String
token: String
user: User
2021-08-20 23:17:15 +00:00
}
type UserResult {
2021-10-30 19:37:57 +00:00
error: String
user: User
2021-08-20 23:17:15 +00:00
}
type MessageResult {
2021-10-30 19:37:57 +00:00
error: String
message: Message
2021-08-20 23:17:15 +00:00
}
input ShoutInput {
2021-10-30 19:37:57 +00:00
slug: String!
body: String!
2021-11-04 00:21:25 +00:00
# replyTo: String # another shout
# tags: [String] # actual values
2021-11-10 08:42:29 +00:00
topic_ids: [Int]
2021-10-30 19:37:57 +00:00
title: String
subtitle: String
versionOf: String
visibleForRoles: [String] # role ids are strings
visibleForUsers: [Int]
2021-08-21 00:40:41 +00:00
}
input ProfileInput {
2021-10-30 19:37:57 +00:00
email: String
username: String
userpic: String
2021-08-20 23:17:15 +00:00
}
2021-11-26 00:41:20 +00:00
input CommunityInput {
2021-11-27 07:09:34 +00:00
title: String!
desc: String
pic: String
2021-11-26 00:41:20 +00:00
}
2021-08-20 23:17:15 +00:00
type ShoutResult {
2021-10-30 19:37:57 +00:00
error: String
shout: Shout
2021-08-20 23:17:15 +00:00
}
2021-11-21 11:04:38 +00:00
type CommentResult {
error: String
comment: Comment
}
2021-11-24 07:36:06 +00:00
enum MessageStatus {
NEW
UPDATED
DELETED
}
type MessageWithStatus {
status: MessageStatus!
message: Message!
}
2021-08-20 23:17:15 +00:00
################################### Mutation
type Mutation {
2021-10-30 19:37:57 +00:00
# message
createMessage(body: String!, replyTo: Int): MessageResult!
updateMessage(id: Int!, body: String!): MessageResult!
deleteMessage(messageId: Int!): Result!
# auth
confirmEmail(token: String!): AuthResult!
requestPasswordReset(email: String!): Boolean!
confirmPasswordReset(token: String!): Boolean!
registerUser(email: String!, password: String): AuthResult!
# updatePassword(password: String!, token: String!): Token!
# invalidateAllTokens: Boolean!
# invalidateTokenById(id: Int!): Boolean!
# requestEmailConfirmation: User!
# shout
createShout(input: ShoutInput!): ShoutResult!
updateShout(id: Int!, input: ShoutInput!): ShoutResult!
deleteShout(id: Int!): Result!
rateShout(shout_id: Int!, value: Int!): Result!
viewShout(shout_id: Int!): Result!
# user profile
# rateUser(value: Int!): Result!
# updateOnlineStatus: Result!
updateProfile(profile: ProfileInput!): Result!
# topics
topicSubscribe(slug: String!): Result!
topicUnsubscribe(slug: String!): Result!
2021-11-26 00:41:20 +00:00
2021-11-21 11:04:38 +00:00
createComment(body: String!, shout: Int!, replyTo: Int): CommentResult!
updateComment(id: Int!, body: String!): CommentResult!
deleteComment(id: Int!): Result!
2021-11-24 06:23:48 +00:00
rateComment(id: Int!, value: Int!): Result!
2021-11-26 00:41:20 +00:00
createCommunity(title: String!, desc: String!): Community!
2021-11-26 00:41:20 +00:00
updateCommunity(community: CommunityInput!): Community!
deleteCommunity(id: Int!): Result!
2021-08-20 23:17:15 +00:00
}
################################### Query
type Query {
2021-10-30 19:37:57 +00:00
# auth
isEmailFree(email: String!): Result!
signIn(email: String!, password: String): AuthResult!
signOut: Result!
# profile
getCurrentUser: UserResult!
getUserBySlug(slug: String!): UserResult!
# rateUser(shout: Int): Int!
2021-11-24 09:09:47 +00:00
userRoles: [Role]!
2021-10-30 19:37:57 +00:00
# messages
getMessages(count: Int = 100, page: Int = 1): [Message!]!
# shouts
2021-11-25 02:45:22 +00:00
getShoutBySlug(slug: String!): Shout! # NOTE: with .comments: Comments[]
2021-10-30 19:37:57 +00:00
shoutsByTopic(topic: String!, limit: Int!): [Shout]!
shoutsByAuthor(author: String!, limit: Int!): [Shout]!
shoutsByCommunity(community: String!, limit: Int!): [Shout]!
# mainpage
2021-10-31 15:09:16 +00:00
topViewed(limit: Int): [Shout]!
2021-10-31 14:55:13 +00:00
topMonth(limit: Int): [Shout]!
topOverall(limit: Int): [Shout]!
2021-10-31 10:26:14 +00:00
recents(limit: Int): [Shout]!
2021-10-30 19:37:57 +00:00
topAuthors(limit: Int): [User]!
# topics
2021-11-27 06:15:02 +00:00
topicsAll: [Topic]!
2021-10-30 19:37:57 +00:00
topicsBySlugs(slugs: [String]!): [Topic]!
topicsByCommunity(community: String!): [Topic]!
topicsByAuthor(author: String!): [Topic]!
# getOnlineUsers: [User!]!
2021-11-26 00:41:20 +00:00
2021-11-24 12:11:59 +00:00
# communities
getCommunity(slug: String): Community!
getCommunities: [Community]!
2021-11-25 02:45:22 +00:00
# my feed
authorsBySlugs(slugs: [String]!): [User]!
2021-08-20 23:17:15 +00:00
}
############################################ Subscription
type Subscription {
2021-11-24 07:36:06 +00:00
messageChanged: MessageWithStatus!
2021-10-30 19:37:57 +00:00
onlineUpdated: [User!]!
shoutUpdated: Shout!
userUpdated: User!
2021-11-04 16:37:41 +00:00
topicUpdated(user_id: Int!): Shout!
2021-08-20 23:17:15 +00:00
}
############################################ Entities
2021-11-24 09:09:47 +00:00
type Resource {
id: Int!
name: String!
}
type Operation {
id: Int!
name: String!
}
type Permission {
operation_id: Int!
resource_id: Int!
}
2021-08-20 23:17:15 +00:00
type Role {
2021-10-30 19:37:57 +00:00
id: Int!
name: String!
community: Int!
desc: String
2021-11-24 09:09:47 +00:00
permissions: [Permission!]!
2021-08-20 23:17:15 +00:00
}
type Rating {
2021-10-30 19:37:57 +00:00
createdBy: Int!
value: Int!
2021-08-20 23:17:15 +00:00
}
type Notification {
2021-10-30 19:37:57 +00:00
kind: String! # unique primary key
template: String!
variables: [String]
2021-08-20 23:17:15 +00:00
}
type UserNotification {
2021-10-30 19:37:57 +00:00
id: Int! # primary key
user: Int!
kind: String! # NotificationTemplate.name
values: [String]
2021-08-20 23:17:15 +00:00
}
type User {
2021-10-30 19:37:57 +00:00
id: Int!
username: String! # to login, ex. email
createdAt: DateTime!
slug: String!
name: String # to display
email: String
password: String
oauth: String # provider:token
userpic: String
links: [String]
emailConfirmed: Boolean # should contain all emails too
muted: Boolean
updatedAt: DateTime
wasOnlineAt: DateTime
rating: Int
bio: String
notifications: [Int]
topics: [String] # user subscribed topics
communities: [Int] # user participating communities
old_id: String
2021-08-20 23:17:15 +00:00
}
type Message {
2021-10-30 19:37:57 +00:00
author: Int!
body: String!
createdAt: DateTime!
id: Int!
replyTo: Int
updatedAt: DateTime!
visibleForUsers: [Int]!
2021-08-20 23:17:15 +00:00
}
2021-09-03 16:01:31 +00:00
type Comment {
2021-10-30 19:37:57 +00:00
id: Int!
author: Int!
body: String!
2021-11-21 11:04:38 +00:00
replyTo: Int
2021-10-30 19:37:57 +00:00
createdAt: DateTime!
updatedAt: DateTime
updatedBy: Int
shout: Int!
deletedAt: DateTime
deletedBy: Int
rating: Int
2021-11-22 06:38:14 +00:00
ratings: [CommentRating]
2021-10-30 19:37:57 +00:00
views: Int
old_id: String
old_thread: String
2021-10-13 17:46:30 +00:00
}
type CommentRating {
2021-10-30 19:37:57 +00:00
id: Int!
comment_id: Int!
createdBy: Int!
createdAt: DateTime!
value: Int!
2021-09-03 16:01:31 +00:00
}
2021-08-20 23:17:15 +00:00
# is publication
type Shout {
2021-10-30 19:37:57 +00:00
id: Int!
slug: String!
body: String!
createdAt: DateTime!
authors: [User!]!
comments: [Comment]
2021-11-22 06:38:14 +00:00
ratings: [Rating]
2021-10-30 19:37:57 +00:00
visibleFor: [User]
community: Int
cover: String
layout: String
rating: Int
views: Int
2021-11-04 00:21:25 +00:00
# replyTo: Shout
2021-10-30 19:37:57 +00:00
versionOf: Shout
tags: [String] # actual values
2021-11-10 08:42:29 +00:00
topics: [Topic]
2021-10-30 19:37:57 +00:00
title: String
subtitle: String
updatedAt: DateTime
updatedBy: Int # can be user id?
deletedAt: DateTime
deletedBy: Int
publishedBy: Int # if there is no published field - it is not published
publishedAt: DateTime
old_id: String
2021-08-20 23:17:15 +00:00
}
2021-08-26 21:14:20 +00:00
type Community {
2021-10-30 19:37:57 +00:00
slug: String!
name: String!
desc: String
pic: String!
2021-08-26 21:14:20 +00:00
}
2021-08-20 23:17:15 +00:00
type Topic {
2021-10-30 19:37:57 +00:00
slug: String! # ID
title: String
body: String
pic: String
parents: [String] # NOTE: topic can have parent topics
children: [String] # and children
cat_id: String
2021-08-20 23:17:15 +00:00
}
# TODO: resolvers to add/remove topics from publication
type Proposal {
2021-10-30 19:37:57 +00:00
body: String!
shout: Int!
range: String # full / 0:2340
author: Int!
createdAt: DateTime!
2021-08-20 23:17:15 +00:00
}
type Token {
2021-10-30 19:37:57 +00:00
createdAt: DateTime!
expiresAt: DateTime
id: Int!
ownerId: Int!
usedAt: DateTime
value: String!
2021-08-28 10:13:50 +00:00
}