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

Some new resolvers

parent ac01a3d9
No related branches found
No related tags found
No related merge requests found
...@@ -44,7 +44,25 @@ export const resolvers = { ...@@ -44,7 +44,25 @@ export const resolvers = {
return user && connectors.getMetaGroupIfVisible(user, args.uid); return user && connectors.getMetaGroupIfVisible(user, args.uid);
}, },
// message query /*
* Message queries.
*/
allPosts: function(obj, args, context) {
console.log("Accessing all posts...");
return knex.select().from("posts");
},
post: function (obj, args, context) {
return knex.select().from("posts").where('id',args.id).then(res => res[0]);
},
allAnnouncements: function(obj, args, context) {
return knex.select().from("announcements");
},
allEvents: function(obj, args, context) {
return knex.select().from("events");
},
// user queries // user queries
...@@ -183,16 +201,14 @@ export const resolvers = { ...@@ -183,16 +201,14 @@ export const resolvers = {
}, },
Post: {
authors: (obj, args, context) => {
return knex.select().from('groups').whereIn('uid',obj.authors);
}
},
Message: { Message: {
__resolveType: function(obj){ __resolveType: function(obj) {
return obj.type; return obj.type;
},
authors: (obj, args, context) => {
return knex.select().from('groups').whereIn('uid', obj.authors);
} }
}, },
...@@ -231,15 +247,15 @@ export const resolvers = { ...@@ -231,15 +247,15 @@ export const resolvers = {
// @rights viewer(obj.uid) // @rights viewer(obj.uid)
Group: { Group: {
__resolveType: (obj) => { __resolveType: (obj) => {
console.log(obj);
switch(obj.type){ let isSimple = knex.select().from("groups").where("uid", obj.uid)
case "simple": .then(res => {
return "SimpleGroup"; console.log(res);
case "meta": return res;
return "MetaGroup"; });
default:
return undefined; return undefined;
}
} }
}, },
......
...@@ -14,10 +14,12 @@ const RootTypes = ` ...@@ -14,10 +14,12 @@ const RootTypes = `
# message queries # message queries
allMessages: [Message] allMessages: [Message]
allEvents: [Event]
message(id: ID!): Message message(id: ID!): Message
allPosts: [Post]
post(id: ID!): Post
allEvents: [Event]
allAnnouncements: [Announcement] allAnnouncements: [Announcement]
# user queries # user queries
user(uid: ID!) : User user(uid: ID!) : User
......
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