core/schema.graphql
2022-10-21 09:48:36 +03:00

510 lines
9.9 KiB
GraphQL

scalar DateTime
################################### Payload ###################################
type MessageResult {
error: String
message: Message
}
enum MessageStatus {
NEW
UPDATED
DELETED
}
type ChatUpdatedResult {
error: String
status: MessageStatus
message: Message
}
type CreateChatResult {
chatId: String
error: String
}
type EnterChatResult {
chat: Chat
messages: [Message]
error: String
}
type ChatResult {
error: String
members: [User]!
createdAt: DateTime!
createdBy: User
messages: [Message]
title: String
}
type UserFollowings {
unread: Int
topics: [String]
authors: [String]
reactions: [Int]
communities: [String]
}
type AuthResult {
error: String
token: String
user: User
news: UserFollowings
}
type Result {
error: String
shout: Shout
shouts: [Shout]
author: User
authors: [User]
reaction: Reaction
reactions: [Reaction]
topic: Topic
topics: [Topic]
community: Community
communities: [Community]
}
enum ReactionStatus {
NEW
UPDATED
CHANGED
EXPLAINED
DELETED
}
type ReactionUpdating {
error: String
status: ReactionStatus
reaction: Reaction
}
################################### Inputs ###################################
input ShoutInput {
slug: String!
body: String!
community: String!
mainTopic: String
topic_slugs: [String]
title: String
subtitle: String
versionOf: String
visibleForRoles: [String] # role ids are strings
visibleForUsers: [Int]
}
input ProfileInput {
name: String
userpic: String
links: [String]
bio: String
}
input CommunityInput {
title: String!
desc: String
pic: String
}
input CollectionInput {
title: String!
desc: String
pic: String
}
input TopicInput {
slug: String!
community: String!
title: String
body: String
pic: String
children: [String]
parents: [String]
}
input ReactionInput {
kind: Int!
shout: String!
range: String
body: String
replyTo: Int
}
enum FollowingEntity {
TOPIC
AUTHOR
COMMUNITY
REACTIONS
}
################################### Mutation
type Mutation {
# inbox
createChat(description: String): CreateChatResult!
inviteChat(chatId: String!, userslug: String!): Result!
createMessage(chatId: String!, body: String!, replyTo: Int): MessageResult!
updateMessage(chatId: String!, id: Int!, body: String!): MessageResult!
deleteMessage(chatId: String!, id: Int!): Result!
markAsRead(chatId: String!, ids: [Int]!): Result!
# auth
refreshSession: AuthResult!
registerUser(email: String!, password: String, name: String): AuthResult!
sendLink(email: String!, lang: String): Result!
confirmEmail(code: String!): AuthResult!
# shout
createShout(input: ShoutInput!): Result!
updateShout(input: ShoutInput!): Result!
deleteShout(slug: String!): Result!
# user profile
rateUser(slug: String!, value: Int!): Result!
# updateOnlineStatus: Result!
updateProfile(profile: ProfileInput!): Result!
# topics
createTopic(input: TopicInput!): Result!
# TODO: mergeTopics(t1: String!, t2: String!): Result!
updateTopic(input: TopicInput!): Result!
destroyTopic(slug: String!): Result!
# reactions
createReaction(reaction: ReactionInput!): Result!
updateReaction(reaction: ReactionInput!): Result!
deleteReaction(id: Int!): Result!
# community
createCommunity(community: CommunityInput!): Result!
updateCommunity(community: CommunityInput!): Result!
deleteCommunity(slug: String!): Result!
# collection
createCollection(collection: CollectionInput!): Result!
updateCollection(collection: CollectionInput!): Result!
deleteCollection(slug: String!): Result!
# collab
inviteAuthor(author: String!, shout: String!): Result!
removeAuthor(author: String!, shout: String!): Result!
# following
follow(what: FollowingEntity!, slug: String!): Result!
unfollow(what: FollowingEntity!, slug: String!): Result!
# seen
incrementView(shout: String!): Result!
}
################################### Query
type Query {
# inbox
myChats: [ChatResult]!
enterChat(chatId: String!): ChatResult!
loadChat(chatId: String!, size: Int!, page: Int!): [Message]!
# auth
isEmailUsed(email: String!): Boolean!
signIn(email: String!, password: String, lang: String): AuthResult!
signOut: AuthResult!
# profile
getUsersBySlugs(slugs: [String]!): [User]!
userFollowers(slug: String!): [User]!
userFollowedAuthors(slug: String!): [User]!
userFollowedTopics(slug: String!): [Topic]!
userFollowedCommunities(slug: String!): [Community]!
userReactedShouts(slug: String!): [Shout]! # test
getUserRoles(slug: String!): [Role]!
authorsAll: [User]!
# shouts
getShoutBySlug(slug: String!): Shout!
shoutsForFeed(offset: Int!, limit: Int!): [Shout]! # test
shoutsByTopics(slugs: [String]!, offset: Int!, limit: Int!): [Shout]!
shoutsByAuthors(slugs: [String]!, offset: Int!, limit: Int!): [Shout]!
shoutsByCommunities(slugs: [String]!, offset: Int!, limit: Int!): [Shout]!
# topReacted(offset: Int!, limit: Int!): [Shout]!
topAuthors(offset: Int!, limit: Int!): [Author]! # by User.rating
topPublished(daysago: Int!, offset: Int!, limit: Int!): [Shout]!
topMonth(offset: Int!, limit: Int!): [Shout]! # TODO: implement topPublishedAfter(day, offset, limit)
topOverall(offset: Int!, limit: Int!): [Shout]!
topCommented(offset: Int!, limit: Int!): [Shout]!
recentPublished(offset: Int!, limit: Int!): [Shout]! # homepage
recentReacted(offset: Int!, limit: Int!): [Shout]! # TODO: use in design!
recentCommented(offset: Int!, limit: Int!): [Shout]!
recentAll(offset: Int!, limit: Int!): [Shout]!
recentCandidates(offset: Int!, limit: Int!): [Shout]!
# reactons
reactionsByAuthor(slug: String!, offset: Int!, limit: Int!): [Reaction]!
reactionsForShouts(shouts: [String]!, offset: Int!, limit: Int!): [Reaction]!
# collab
getCollabs: [Collab]!
# migrate
markdownBody(body: String!): String!
# topics
topicsAll: [Topic]!
topicsRandom(amount: Int): [Topic]!
topicsByCommunity(community: String!): [Topic]!
topicsByAuthor(author: String!): [Topic]!
# collections
collectionsAll: [Collection]!
getUserCollections(author: String!): [Collection]!
shoutsByCollection(collection: String!, offset: Int!, limit: Int!): [Shout]!
# communities
getCommunity(slug: String): Community!
getCommunities: [Community]! # all
# search
searchQuery(q: String, offset: Int!, limit: Int!): [Shout]
}
############################################ Subscription
type Subscription {
chatUpdated(chatId: String!): ChatUpdatedResult!
onlineUpdated: [User!]!
shoutUpdated: Shout!
userUpdated: User!
reactionUpdated(shout: String!): ReactionUpdating!
}
############################################ Entities
type Resource {
id: Int!
name: String!
}
type Operation {
id: Int!
name: String!
}
type Permission {
operation_id: Int!
resource_id: Int!
}
type Role {
id: Int!
name: String!
community: String!
desc: String
permissions: [Permission!]!
}
type Rating {
rater: String!
value: Int!
}
type Notification {
kind: String! # unique primary key
template: String!
variables: [String]
}
type UserNotification {
id: Int! # primary key
user: Int!
kind: String! # NotificationTemplate.name
values: [String]
}
type User {
id: Int!
username: String! # to login, ex. email
createdAt: DateTime!
lastSeen: 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
ratings: [Rating]
bio: String
notifications: [Int]
communities: [Int] # user participating communities
oid: String
}
type Collab {
authors: [String]!
invites: [String]
createdAt: DateTime!
title: String
body: String
}
enum ReactionKind {
LIKE
DISLIKE
AGREE
DISAGREE
PROOF
DISPROOF
COMMENT
QUOTE
PROPOSE
ASK
ACCEPT
REJECT
}
type Reaction {
id: Int!
shout: Shout!
createdAt: DateTime!
createdBy: User!
updatedAt: DateTime
deletedAt: DateTime
deletedBy: User
range: String # full / 0:2340
kind: ReactionKind!
body: String
replyTo: Reaction
stat: Stat
old_id: String
old_thread: String
}
type Author {
slug: String!
name: String!
userpic: String
caption: String # only for full shout
bio: String
links: [String]
}
# is publication
type Shout {
id: Int!
slug: String!
body: String!
createdAt: DateTime!
authors: [Author]
lang: String
community: String
cover: String
layout: String
draft: Boolean
versionOf: Shout # translations and adaptations
visibleFor: [User]
topics: [Topic]
mainTopic: String
title: String
subtitle: String
updatedAt: DateTime
updatedBy: User
deletedAt: DateTime
deletedBy: User
publishedBy: User
publishedAt: DateTime
stat: Stat
}
type Stat {
viewed: Int
reacted: Int
rating: Int
commented: Int
ranking: Int
}
type Community {
slug: String!
name: String!
desc: String
pic: String!
createdAt: DateTime!
createdBy: User!
}
type Collection {
slug: String!
title: String!
desc: String
amount: Int
publishedAt: DateTime
createdAt: DateTime!
createdBy: User!
}
type TopicStat {
shouts: Int!
followers: Int!
authors: Int!
viewed: Int!
reacted: Int!
commented: Int
rating: Int
}
type Topic {
slug: String! # ID
title: String
body: String
pic: String
parents: [String] # NOTE: topic can have parent topics
children: [String] # and children
community: Community!
stat: TopicStat
oid: String
}
type Token {
createdAt: DateTime!
expiresAt: DateTime
id: Int!
ownerId: Int!
usedAt: DateTime
value: String!
}
type Message {
author: String!
chatRoom: Int!
body: String!
createdAt: DateTime!
id: Int!
replyTo: Int
updatedAt: DateTime!
visibleForUsers: [Int]!
}
type Chat {
id: Int!
createdAt: DateTime!
createdBy: User!
updatedAt: DateTime!
title: String
description: String
users: [User]!
messages: [Message]
}