Skip to content
Snippets Groups Projects
Commit 4a9d4856 authored by Wilson JALLET's avatar Wilson JALLET :money_with_wings:
Browse files

Un-breaking stuff

parent 6beabd02
No related branches found
No related tags found
No related merge requests found
......@@ -4,14 +4,14 @@
*/
import knex from '../../db/knex_router';
import { listGroups, listMembers} from '../ldap/ldap_data';
// import { listGroups, listMembers } from '../ldap/ldap_data';
import { makeExecutableSchema } from 'graphql-tools';
import { request } from 'https';
const typeDefs = `
type Query {
allGroups: [Group]!
group(id : ID) : Group!
allGroups: [Group]
group(id: ID) : [Group]
}
type Group {
......@@ -25,12 +25,13 @@ const typeDefs = `
`;
const getAllVisibleGroups = (user) => {
let group_ids = listGroups(user.id);
return knex.select().from('groups').whereIn('id', group_ids);
// let group_ids = listGroups(user.id);
return knex.select().from('groups')/*.whereIn('id', group_ids)*/;
};
const getGroupIfVisible = (user, id) => {
return this.getAllVisibleGroups(user).where('id', id);
return getAllVisibleGroups(user)/*.where('id', id).then(function(table) {
console.log(JSON.stringify(table,null,2))*/;
};
const resolvers = {
......@@ -39,6 +40,7 @@ const resolvers = {
return getAllVisibleGroups(context.user);
},
group: (obj, args, context) => {
console.log(args.id);
return getGroupIfVisible(context.user, args.id);
}
}
......
......@@ -116,7 +116,6 @@ function TOL(c0="", c1="", c2="", c3="", c4="", c5="", c6="", c7="", c8="", c9="
// Synthaxe d'utilisation
//listGroups("quentin.louis").then((meList) => { console.log(meList); });
TOL("","","","","","","faerix","","","","","","").then((meList) => { console.log(meList); });
/* Partage pour le reste du monde ; même remarque synthaxe
export { listGroups, listMembers, TOL }; */
......
......@@ -32,11 +32,19 @@ server.use(favicon(path.resolve('./','assets','favicon.ico')));
server.use(morgan('dev'));
// Charge le middleware express pour GraphQL
server.use('/graphql', bodyParser.json(),
server.use('/graphql', bodyParser.json(), cors(),
graphqlExpress(req => {
let uid;
try {
uid = req.session.id;
} catch (err) {
uid = "1";
}
return {
schema : schema,
context : {user : {id : req.session.id}}
context : {user : {id : uid}}
};
}));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment