feat: navigation, editor improvements + graphql refactor

This commit is contained in:
NGPixel
2018-03-18 23:12:56 -04:00
parent 8462e18fc5
commit 3f0adc5daf
20 changed files with 284 additions and 400 deletions

View File

@@ -11,7 +11,7 @@ module.exports = {
createFolder(obj, args) {
return WIKI.db.Folder.create(args)
},
deleteGroup(obj, args) {
deleteFolder(obj, args) {
return WIKI.db.Folder.destroy({
where: {
id: args.id

View File

@@ -5,12 +5,18 @@ const gql = require('graphql')
module.exports = {
Query: {
groups(obj, args, context, info) {
async groups() { return {} }
},
Mutation: {
async groups() { return {} }
},
GroupQuery: {
list(obj, args, context, info) {
return WIKI.db.Group.findAll({ where: args })
}
},
Mutation: {
assignUserToGroup(obj, args) {
GroupMutation: {
assignUser(obj, args) {
return WIKI.db.Group.findById(args.groupId).then(grp => {
if (!grp) {
throw new gql.GraphQLError('Invalid Group ID')
@@ -23,10 +29,10 @@ module.exports = {
})
})
},
createGroup(obj, args) {
create(obj, args) {
return WIKI.db.Group.create(args)
},
deleteGroup(obj, args) {
delete(obj, args) {
return WIKI.db.Group.destroy({
where: {
id: args.id
@@ -34,7 +40,7 @@ module.exports = {
limit: 1
})
},
removeUserFromGroup(obj, args) {
unassignUser(obj, args) {
return WIKI.db.Group.findById(args.groupId).then(grp => {
if (!grp) {
throw new gql.GraphQLError('Invalid Group ID')
@@ -47,7 +53,7 @@ module.exports = {
})
})
},
renameGroup(obj, args) {
update(obj, args) {
return WIKI.db.Group.update({
name: args.name
}, {

View File

@@ -95,15 +95,6 @@ type Folder implements Base {
files: [File]
}
type Group implements Base {
id: Int!
createdAt: Date
updatedAt: Date
name: String!
users: [User]
rights: [Right]
}
type Right implements Base {
id: Int!
createdAt: Date
@@ -168,7 +159,6 @@ type Query {
documents(id: Int, path: String): [Document]
files(id: Int): [File]
folders(id: Int, name: String): [Folder]
groups(id: Int, name: String): [Group]
rights(id: Int): [Right]
search(q: String, tags: [String]): [SearchResult]
settings(key: String): [Setting]
@@ -192,11 +182,6 @@ type Mutation {
documentId: Int!
): OperationResult
assignUserToGroup(
userId: Int!
groupId: Int!
): OperationResult
createComment(
userId: Int!
documentId: Int!
@@ -213,10 +198,6 @@ type Mutation {
name: String!
): Folder
createGroup(
name: String!
): Group
createTag(
name: String!
): Tag
@@ -246,10 +227,6 @@ type Mutation {
id: Int!
): OperationResult
deleteGroup(
id: Int!
): OperationResult
deleteTag(
id: Int!
): OperationResult
@@ -306,11 +283,6 @@ type Mutation {
name: String!
): OperationResult
renameGroup(
id: Int!
name: String!
): OperationResult
renameTag(
id: Int!
key: String!
@@ -325,11 +297,6 @@ type Mutation {
rightId: Int!
): OperationResult
removeUserFromGroup(
userId: Int!
groupId: Int!
): OperationResult
resetUserPassword(
id: Int!
): OperationResult

View File

@@ -0,0 +1,69 @@
# ===============================================
# GROUPS
# ===============================================
extend type Query {
groups: GroupQuery
}
extend type Mutation {
groups: GroupMutation
}
# -----------------------------------------------
# QUERIES
# -----------------------------------------------
type GroupQuery {
list(
filter: String
orderBy: String
): [Group]
}
# -----------------------------------------------
# MUTATIONS
# -----------------------------------------------
type GroupMutation {
create(
name: String!
): GroupResponse
update(
id: Int!
name: String!
): GroupResponse
delete(
id: Int!
): DefaultResponse
assignUser(
groupId: Int!
userId: Int!
): DefaultResponse
unassignUser(
groupId: Int!
userId: Int!
): DefaultResponse
}
# -----------------------------------------------
# TYPES
# -----------------------------------------------
type GroupResponse {
operation: ResponseStatus!
group: Group
}
type Group {
id: Int!
name: String!
rights: [String]
users: [User]
createdAt: Date!
updatedAt: Date!
}