From d3cf4869c54a02ae55a1d9023157cd41b7d5db2f Mon Sep 17 00:00:00 2001 From: anatole <anatole.romon@polytechnique.edu> Date: Mon, 16 Apr 2018 03:03:28 +0200 Subject: [PATCH] resolvers des divers messages --- src/graphql/connectors/connectors.js | 2 +- src/graphql/resolvers.js | 53 ++++++++++++++++++++++++++++ src/graphql/typeDefs/objects.js | 22 ++++++++---- 3 files changed, 70 insertions(+), 7 deletions(-) diff --git a/src/graphql/connectors/connectors.js b/src/graphql/connectors/connectors.js index bd55ad6..90fbd8f 100644 --- a/src/graphql/connectors/connectors.js +++ b/src/graphql/connectors/connectors.js @@ -309,7 +309,7 @@ export async function getYourGroupHostEventRequests(user, recipientUID){ //Don't forget the argument user is the guy who makes the request, not the user we want -export const getUser = (user, uid) => { +export const getUser = (user, uid, db) => { const refactorer = (data) => { if (typeof data.brRoom == 'string') data.brRoom = [data.brRoom]; diff --git a/src/graphql/resolvers.js b/src/graphql/resolvers.js index 310a738..d61fa74 100644 --- a/src/graphql/resolvers.js +++ b/src/graphql/resolvers.js @@ -255,6 +255,59 @@ export const resolvers = { } }, + PrivatePost : { + + authors: async function(obj, args, context){ + return { + singleUser : await connectors.getUser(context.user, obj.author_uid, obj.author_db) + }; + }, + + recipient: async function(obj, args, context){ + return { + singleGroup : await connectors.getGroup(context.user, obj.recipient_uid) + }; + } + }, + + Question : { + + authors: async function(obj, args, context){ + return { + singleUser : await connectors.getUser(context.user, obj.author_uid, obj.author_db) + }; + }, + + recipient: async function(obj, args, context){ + return { + singleGroup : await connectors.getGroup(context.user, obj.recipient_uid) + }; + }, + + forAnswer: function(obj, args, context){ + return obj.for_answer; + } + }, + + Answer : { + + authors: async function(obj, args, context){ + return { + singleGroup : await connectors.getGroup(context.user, obj.author_uid) + }; + }, + + recipient: async function(obj, args, context){ + return { + singleGroup : await connectors.getGroup(context.user, obj.recipient_uid) + }; + }, + + forQuestion: function(obj, args, context){ + return obj.for_question; + } + }, + // @rights viewer(obj.uid) Group: { __resolveType: async (obj) => { diff --git a/src/graphql/typeDefs/objects.js b/src/graphql/typeDefs/objects.js index 08093c6..02166d2 100644 --- a/src/graphql/typeDefs/objects.js +++ b/src/graphql/typeDefs/objects.js @@ -44,6 +44,16 @@ const Group = ` # Dernière mise à jour du groupe. updatedAt: String! + # member requests + + # Les posts prives dans ce groupe + # privatePosts: [PrivatePost] + # Les questions addressees à ce groupe + # questions: [Question] + # Les reponses donnees par ce groupe + # answers: [Answer] + + } # Le groupe de base, dont les membres sont des utilisateurs : binets, Kès... @@ -165,8 +175,8 @@ const Message = ` title: String! content: String! - authors: User - recipient: Group + authors: Author # User + recipient: Recipient # Group } # Question posée par un user à un groupe @@ -177,8 +187,8 @@ const Message = ` title: String! content: String! - authors: User - recipient: Group + authors: Author # User + recipient: Recipient # Group # Une annonce éventuellement concernée par cette question. # Null si la question ne concerne pas une annonce particulière @@ -197,8 +207,8 @@ const Message = ` title: String! content: String! - authors: Group - recipient: Group + authors: Author # Group + recipient: Recipient # Group # La question à laquelle cette Answer répond. Non-nullable bien sûr forQuestion: Question! -- GitLab