From a44c5d813e4987d15094f8ca3a733ebd3195efcf Mon Sep 17 00:00:00 2001
From: ManifoldFR <wilson.jallet@gmail.com>
Date: Wed, 21 Mar 2018 01:33:05 +0100
Subject: [PATCH] Post.authors work

---
 src/graphql/connectors/connectors.js |  1 +
 src/graphql/connectors/selectors.js  |  4 ++--
 src/graphql/resolvers.js             | 24 +++++++++++++-----------
 3 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/src/graphql/connectors/connectors.js b/src/graphql/connectors/connectors.js
index 836afcb..d2257ce 100644
--- a/src/graphql/connectors/connectors.js
+++ b/src/graphql/connectors/connectors.js
@@ -582,6 +582,7 @@ export async function getMetaGroupsFromCallbacks (user, selection){
  * @rights user
  */
 export async function getGroupsFromCallbacks(user, cbList){
+    console.log(cbList);
     let all_simple_groups = await getSimpleGroupsFromCallbacks(user, cbList);
     let all_meta_groups = await getMetaGroupsFromCallbacks(user, cbList);
     return all_simple_groups.concat(all_meta_groups);
diff --git a/src/graphql/connectors/selectors.js b/src/graphql/connectors/selectors.js
index 1807f7c..9cde12e 100644
--- a/src/graphql/connectors/selectors.js
+++ b/src/graphql/connectors/selectors.js
@@ -15,11 +15,11 @@
  * @rights user
  */
 export async function visibleGroups(user){
-    let group_ids = await user.ldap_access.listerGroupes(user.uid);
+    let group_ids = await user.ldap_access.listGroups(user.uid);
     return function (global_query_builder){
         if (typeof group_ids == "undefined")
             throw "invalid user";
-        var membered_groups = qb => qb.select('simple_groups.uid').from('simple_groups').whereIn('uid', group_ids.concat(['kes']));
+        var membered_groups = qb => qb.select('uid').from('simple_groups').whereIn('uid', group_ids.concat(['kes']));
         var directly_visible_simple_groups = qb =>  qb.with('membered_groups', membered_groups)
             .select('simple_groups.uid').from('simple_groups').distinct()
             .innerJoin('membered_groups',
diff --git a/src/graphql/resolvers.js b/src/graphql/resolvers.js
index 471cb3d..6256bc6 100644
--- a/src/graphql/resolvers.js
+++ b/src/graphql/resolvers.js
@@ -205,12 +205,15 @@ export const resolvers = {
 
         __resolveType: function(obj) {
             return obj.type;
-        },
+        }
 
+    },
+
+    Post: {
         authors: (obj, args, context) => {
+            console.log(obj);
             return knex.select().from('groups').whereIn('uid', obj.authors);
         }
-
     },
 
     Announcement: {
@@ -246,21 +249,20 @@ export const resolvers = {
 
     // @rights viewer(obj.uid)
     Group: {
-        __resolveType: (obj) => {
-            console.log(obj);
+        __resolveType: async (obj) => {
             
-            let isSimple = knex.select().from("groups").where("uid", obj.uid)
-                .then(res => {
-                    console.log(res);
-                    return res;
-                });
-            
-            return undefined;
+            switch(obj.type) {
+            case "simple":
+                return "SimpleGroup";
+            case "meta":
+                return "MetaGroup";
+            }
         }
     },
 
     // @rights viewer(obj.uid)
     SimpleGroup: {
+        
         members: (obj, args, context) => {
             return connectors.utilisateur.listMembers(context.user,obj.uid);
         }
-- 
GitLab