From 5e6f65b80f7b85696f87a89a64d9431c23900be6 Mon Sep 17 00:00:00 2001
From: anatole <anatole.romon@polytechnique.edu>
Date: Thu, 1 Mar 2018 15:50:45 +0100
Subject: [PATCH] =?UTF-8?q?=C3=A7a=20marche=20mageul?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/graphql/schema.js | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/graphql/schema.js b/src/graphql/schema.js
index 6e7c3ba..404674a 100644
--- a/src/graphql/schema.js
+++ b/src/graphql/schema.js
@@ -11,12 +11,12 @@ import { request } from 'https';
 const typeDefs = `
     type Query {
         allGroups: [Group]
-        group(id: ID) : Group
+        group(uid: ID) : Group
     }
 
     type Group {
         name: String
-        id: ID
+        uid: ID
         website: String
         updatedAt: String
         description: String
@@ -27,16 +27,16 @@ const typeDefs = `
 const getAllVisibleGroups = (user) => {
 
     var group_ids =   listGroups(user.id).then(res => res);
-    var membered_groups = qb => qb.select().from('groups').whereIn('id', [1, 4]/*group_ids*/);
+    var membered_groups = qb => qb.select().from('groups').whereIn('uid', ['br', 'data']/*group_ids*/);
     return knex.with('membered_groups', membered_groups).select('groups.*').from('groups').innerJoin('membered_groups', 
         function() {
-            this.on('groups.id', '=', 'membered_groups.id').orOn('groups.parent', '=', 'membered_groups.id')
+            this.on('groups.uid', '=', 'membered_groups.uid').orOn('groups.parentuid', '=', 'membered_groups.uid')
         }
     );
 };
     
-const getGroupIfVisible = (user, id) => {
-    return getAllVisibleGroups(user).where('id', id).then(res => {
+const getGroupIfVisible = (user, uid) => {
+    return getAllVisibleGroups(user).where('uid', uid).then(res => {
         return res[0];
     });
 };
@@ -47,7 +47,7 @@ const resolvers = {
             return getAllVisibleGroups(context.user);
         },
         group: (obj, args, context) => {
-            return getGroupIfVisible(context.user, args.id);
+            return getGroupIfVisible(context.user, args.uid);
         }
     }
 };
-- 
GitLab