From f8fca8a21938332493f7a95c925c7e644f1347b3 Mon Sep 17 00:00:00 2001
From: anatole <anatole.romon@polytechnique.edu>
Date: Thu, 1 Mar 2018 15:37:36 +0100
Subject: [PATCH] =?UTF-8?q?requ=C3=A8tes=20du=20turfu=20avec=20knex?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/graphql/schema.js | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/graphql/schema.js b/src/graphql/schema.js
index 59693ca..ff2b865 100644
--- a/src/graphql/schema.js
+++ b/src/graphql/schema.js
@@ -15,18 +15,23 @@ const typeDefs = `
     }
 
     type Group {
-        name: String!
-        id: ID!
+        name: String
+        id: ID
         website: String
-        updatedAt: String!
+        updatedAt: String
         description: String
-        school: String!
+        school: String
     }
 `;
 
 const getAllVisibleGroups = (user) => {
     var group_ids =   listGroups(user.id).then(res => res);
-    return knex.select().from('groups').whereIn('id', [1, 2, 3]/*group_ids*/);
+    var membered_groups = qb => qb.select().from('groups').whereIn('id', [1, 4]/*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')
+        }
+    );
 };
     
 const getGroupIfVisible = (user, id) => {
-- 
GitLab