core/schema.graphql

390 lines
7.8 KiB
GraphQL

scalar DateTime
################################### Payload ###################################
type CurrentUserInfo {
inbox: Int
topics: [String]!
authors: [String]!
reactions: [String]!
communities: [String]!
}
type AuthResult {
error: String
token: String
user: User
info: CurrentUserInfo
}
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 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 {
# auth
confirmEmail(token: String!): AuthResult!
registerUser(email: String!, password: String): AuthResult!
requestPasswordUpdate(email: String!): Result!
updatePassword(password: String!, token: String!): Result!
# requestEmailConfirmation: User!
# shout
createShout(input: ShoutInput!): Result!
updateShout(input: ShoutInput!): Result!
deleteShout(slug: String!): Result!
viewShout(slug: String!): Result!
viewReaction(reaction_id: Int!): 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(input: ReactionInput!): Result!
updateReaction(id: Int!, body: String!): Result!
deleteReaction(id: Int!): Result!
rateReaction(id: Int!, value: Int!): Result!
# community
createCommunity(community: CommunityInput!): Result!
updateCommunity(community: CommunityInput!): Result!
deleteCommunity(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!
# TODO: transform reaction with body to shout
# NOTE: so-named 'collections' are tuned feeds
# TODO: Feed entity and CRUM: createFeed updateFeed deleteFeed mergeFeeds
}
################################### Query
type Query {
# auth
isEmailUsed(email: String!): Boolean!
signIn(email: String!, password: String): AuthResult!
signOut: AuthResult!
forget(email: String!): AuthResult!
requestPasswordReset(email: String!): AuthResult!
updatePassword(password: String!, token: String!): AuthResult!
getCurrentUser: 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]!
# shouts
getShoutBySlug(slug: String!): Shout!
shoutsForFeed(page: Int!, size: Int!): [Shout]! # test
shoutsByTopics(slugs: [String]!, page: Int!, size: Int!): [Shout]!
shoutsByAuthors(slugs: [String]!, page: Int!, size: Int!): [Shout]!
shoutsByCommunities(slugs: [String]!, page: Int!, size: Int!): [Shout]!
myCandidates(page: Int!, size: Int!): [Shout]! # test
topViewed(page: Int!, size: Int!): [Shout]!
# TODO: topReacted(page: Int!, size: Int!): [Shout]!
topMonth(page: Int!, size: Int!): [Shout]!
topOverall(page: Int!, size: Int!): [Shout]!
recentPublished(page: Int!, size: Int!): [Shout]! # homepage
recentReacted(page: Int!, size: Int!): [Shout]! # test
recentAll(page: Int!, size: Int!): [Shout]!
# reactons
reactionsAll(page: Int!, size: Int!): [Reaction]!
reactionsByAuthor(slug: String!, page: Int!, size: Int!): [Reaction]!
reactionsByShout(slug: String!): [Reaction]!
# collab
inviteAuthor(slug: String!, author: String!): Result!
removeAuthor(slug: String!, author: String!): Result
# topics
topicsAll(page: Int!, size: Int!): [Topic]!
topicsByCommunity(community: String!): [Topic]!
topicsByAuthor(author: String!): [Topic]!
# communities
getCommunity(slug: String): Community!
getCommunities: [Community]! # all
}
############################################ Subscription
type Subscription {
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!
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
ratings: [Rating]
bio: String
notifications: [Int]
communities: [Int] # user participating communities
oid: String
}
enum ReactionKind {
LIKE
DISLIKE
AGREE
DISAGREE
PROOF
DISPROOF
COMMENT
QOUTE
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
}
# is publication
type Shout {
id: Int!
slug: String!
body: String!
createdAt: DateTime!
authors: [User!]!
# ratings: [Rating]
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!
}
type Community {
slug: String!
name: String!
desc: String
pic: String!
createdAt: DateTime!
createdBy: User!
}
type TopicStat {
shouts: Int!
followers: Int!
authors: Int!
viewed: 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!
}