From e2add5a730ceafa6dff84ecce41db488549dcfe0 Mon Sep 17 00:00:00 2001 From: Grzegorz Leoniec Date: Tue, 5 Mar 2019 10:56:47 +0100 Subject: [PATCH] Added (un)shout and (un)follow mutations --- src/schema.graphql | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/schema.graphql b/src/schema.graphql index dd2bfde59..e5a077f2d 100644 --- a/src/schema.graphql +++ b/src/schema.graphql @@ -1,12 +1,45 @@ type Query { isLoggedIn: Boolean! + "Get the currently logged in User based on the given JWT Token" currentUser: User + "Get the latest Network Statistics" statistics: Statistics! } type Mutation { + "Get a JWT Token for the given Email and password" login(email: String!, password: String!): String! signup(email: String!, password: String!): Boolean! report(resource: Resource!, description: String): Report + + "Shout the given Type and ID" + shout(id: ID!, type: ShoutTypeEnum): String! @cypher(statement: """ + MATCH (n {id: $id}) + WHERE $type IN labels(n) + MERGE (:User {id: $cypherParams.currentUserId})-[r:SHOUTED]->(n) + RETURN COUNT(r) > 0 + """) + "Unshout the given Type and ID" + unshout(id: ID!, type: ShoutTypeEnum): Boolean! @cypher(statement: """ + MATCH (:User {id: $cypherParams.currentUserId})-[r:SHOUTED]->(n {id: $id}) + WHERE $type IN labels(n) + DELETE r + RETURN COUNT(r) > 0 + """) + + "Follow the given Type and ID" + follow(id: ID!, type: FollowTypeEnum): Boolean! @cypher(statement: """ + MATCH (n {id: $id}) + WHERE $type IN labels(n) AND NOT $id = $cypherParams.currentUserId + MERGE (:User {id: $cypherParams.currentUserId})-[r:FOLLOWS]->(n) + RETURN COUNT(r) > 0 + """) + "Unfollow the given Type and ID" + unfollow(id: ID!, type: FollowTypeEnum): Boolean! @cypher(statement: """ + MATCH (:User {id: $cypherParams.currentUserId})-[r:FOLLOWS]->(n {id: $id}) + WHERE $type IN labels(n) + DELETE r + RETURN COUNT(r) > 0 + """) } type Statistics { @@ -214,6 +247,16 @@ enum BadgeStatusEnum { permanent temporary } +enum ShoutTypeEnum { + Post + Organization + Project +} +enum FollowTypeEnum { + User + Organization + Project +} type Organization { id: ID!