type Query { isLoggedIn: Boolean! statistics: Statistics! } type Mutation { login(email: String!, password: String!): LoggedInUser signup(email: String!, password: String!): Boolean! } type LoggedInUser { id: ID! slug: String! name: String! avatar:String! email: String! role: String! token: String! } type Statistics { countUsers: Int! countPosts: Int! countComments: Int! countNotifications: Int! countOrganizations: Int! countProjects: Int! countInvites: Int! countFollows: Int! countShouts: Int! } enum VisibilityEnum { Public Friends Private } enum UserGroupEnum { Admin Moderator User } type WrittenPost @relation(name: "WROTE") { from: User to: Post timestamp: Int # TODO: change that to custom Date Type } # type WrittenPost2 { # Post: Post! # timestamp: Int # TODO: change that to custom Date Type # } type WrittenComment @relation(name: "WROTE") { from: User to: Comment timestamp: Int # TODO: change that to custom Date Type } type User { id: ID! name: String email: String slug: String password: String! avatar: String deleted: Boolean disabled: Boolean role: UserGroupEnum friends: [User]! @relation(name: "FRIENDS", direction: "BOTH") friendsCount: Int! @cypher(statement: "MATCH (this)<-[:FRIENDS]->(r:User) RETURN COUNT(r)") following: [User]! @relation(name: "FOLLOWS", direction: "OUT") followingCount: Int! @cypher(statement: "MATCH (this)-[:FOLLOWS]->(r:User) RETURN COUNT(r)") followedBy: [User]! @relation(name: "FOLLOWS", direction: "IN") followedByCount: Int! @cypher(statement: "MATCH (this)<-[:FOLLOWS]-(r:User) RETURN COUNT(r)") #contributions: [WrittenPost]! #contributions2(first: Int = 10, offset: Int = 0): [WrittenPost2]! # @cypher( # statement: "MATCH (this)-[w:WROTE]->(p:Post) RETURN p as Post, w.timestamp as timestamp" # ) contributions: [Post]! @relation(name: "WROTE", direction: "OUT") contributionsCount: Int! @cypher(statement: """ MATCH (this)-[:WROTE]->(r:Post) WHERE (NOT exists(r.deleted) OR r.deleted = false) AND (NOT exists(r.disabled) OR r.disabled = false) RETURN COUNT(r)""" ) comments: [WrittenComment]! commentsCount: Int! @cypher(statement: "MATCH (this)-[:WROTE]->(r:Comment) WHERE NOT r.deleted = true AND NOT r.disabled = true RETURN COUNT(r)") shouted: [Post]! @relation(name: "SHOUTED", direction: "OUT") shoutedCount: Int! @cypher(statement: "MATCH (this)-[:SHOUTED]->(r:Post) WHERE NOT r.deleted = true AND NOT r.disabled = true RETURN COUNT(r)") organizationsCreated: [Organization] @relation(name: "CREATED_ORGA", direction: "OUT") organizationsOwned: [Organization] @relation(name: "OWNING_ORGA", direction: "OUT") blacklisted: [User]! @relation(name: "BLACKLISTED", direction: "OUT") badges: [Badge]! @relation(name: "REWARDED", direction: "IN") badgesCount: Int! @cypher(statement: "MATCH (this)<-[:REWARDED]-(r:Badge) RETURN COUNT(r)") } type Post { id: ID! author: WrittenPost title: String! slug: String content: String! contentExcerpt: String image: String visibility: VisibilityEnum deleted: Boolean disabled: Boolean createdAt: String updatedAt: String relatedContributions: [Post]! @cypher(statement: """ MATCH (this)-[:TAGGED|CATEGORIZED]->(categoryOrTag)<-[:TAGGED|CATEGORIZED]-(post:Post) RETURN DISTINCT post LIMIT 10 """) tags: [Tag]! @relation(name: "TAGGED", direction: "OUT") categories: [Category]! @relation(name: "CATEGORIZED", direction: "OUT") comments: [Comment]! @relation(name: "COMMENTS", direction: "IN") commentsCount: Int! @cypher(statement: "MATCH (this)<-[:COMMENTS]-(r:Comment) RETURN COUNT(r)") shoutedBy: [User]! @relation(name: "SHOUTED", direction: "IN") shoutedCount: Int! @cypher(statement: "MATCH (this)<-[:SHOUTED]-(r:User) WHERE NOT r.deleted = true AND NOT r.disabled = true RETURN COUNT(r)") } type Comment { id: ID! author: WrittenComment content: String! contentExcerpt: String post: Post @relation(name: "COMMENT", direction: "OUT") deleted: Boolean disabled: Boolean } type Category { id: ID! name: String! slug: String icon: String! posts: [Post]! @relation(name: "CATEGORIZED", direction: "IN") postCount: Int! @cypher(statement: "MATCH (this)<-[:CATEGORIZED]-(r:Post) RETURN COUNT(r)") } type Badge { id: ID! key: String! type: BadgeTypeEnum! status: BadgeStatusEnum! icon: String! rewarded: [User]! @relation(name: "REWARDED", direction: "OUT") } enum BadgeTypeEnum { role crowdfunding } enum BadgeStatusEnum { permanent temorary } type Organization { id: ID! createdBy: User @relation(name: "CREATED_ORGA", direction: "IN") ownedBy: [User] @relation(name: "OWNING_ORGA", direction: "IN") name: String! slug: String description: String! descriptionExcerpt: String deleted: Boolean disabled: Boolean tags: [Tag]! @relation(name: "TAGGED", direction: "OUT") categories: [Category]! @relation(name: "CATEGORIZED", direction: "OUT") } type Tag { id: ID! name: String! taggedPosts: [Post]! @relation(name: "TAGGED", direction: "IN") taggedOrganizations: [Organization]! @relation(name: "TAGGED", direction: "IN") taggedCount: Int! @cypher(statement: "MATCH (this)<-[:TAGGED]-(r) RETURN COUNT(r)") deleted: Boolean }