feat: mutations + updated deps
This commit is contained in:
@@ -10,12 +10,14 @@ const _ = require('lodash')
|
||||
const typeDefs = fs.readFileSync(path.join(wiki.SERVERPATH, 'schemas/types.graphql'), 'utf8')
|
||||
|
||||
const DateScalar = require('../schemas/scalar-date')
|
||||
const DocumentResolvers = require('../schemas/resolvers-document')
|
||||
const FolderResolvers = require('../schemas/resolvers-folder')
|
||||
const GroupResolvers = require('../schemas/resolvers-group')
|
||||
const TagResolvers = require('../schemas/resolvers-tag')
|
||||
const UserResolvers = require('../schemas/resolvers-user')
|
||||
|
||||
const resolvers = _.merge(
|
||||
DocumentResolvers,
|
||||
FolderResolvers,
|
||||
GroupResolvers,
|
||||
TagResolvers,
|
||||
|
29
server/schemas/resolvers-document.js
Normal file
29
server/schemas/resolvers-document.js
Normal file
@@ -0,0 +1,29 @@
|
||||
'use strict'
|
||||
|
||||
/* global wiki */
|
||||
|
||||
module.exports = {
|
||||
Query: {
|
||||
documents(obj, args, context, info) {
|
||||
return wiki.db.Document.findAll({ where: args })
|
||||
}
|
||||
},
|
||||
Mutation: {
|
||||
createDocument(obj, args) {
|
||||
return wiki.db.Document.create(args)
|
||||
},
|
||||
deleteDocument(obj, args) {
|
||||
return wiki.db.Document.destroy({
|
||||
where: {
|
||||
id: args.id
|
||||
},
|
||||
limit: 1
|
||||
})
|
||||
}
|
||||
},
|
||||
Document: {
|
||||
tags(doc) {
|
||||
return doc.getTags()
|
||||
}
|
||||
}
|
||||
}
|
@@ -108,7 +108,7 @@ type Tag implements Base {
|
||||
id: Int!
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
key: String!,
|
||||
key: String!
|
||||
documents: [Document]
|
||||
}
|
||||
|
||||
@@ -125,6 +125,11 @@ type User implements Base {
|
||||
groups: [Group]
|
||||
}
|
||||
|
||||
type OperationResult {
|
||||
succeded: Boolean!
|
||||
message: String
|
||||
}
|
||||
|
||||
# Query (Read)
|
||||
type Query {
|
||||
comments(id: Int): [Comment]
|
||||
@@ -143,45 +148,111 @@ type Mutation {
|
||||
assignTagToDocument(
|
||||
tagId: Int!
|
||||
documentId: Int!
|
||||
): Boolean
|
||||
): OperationResult
|
||||
|
||||
assignUserToGroup(
|
||||
userId: Int!
|
||||
groupId: Int!
|
||||
): Boolean
|
||||
): OperationResult
|
||||
|
||||
createDocument(
|
||||
path: String!
|
||||
title: String!
|
||||
subtitle: String
|
||||
): Document
|
||||
|
||||
createFolder(
|
||||
name: String!
|
||||
): Folder
|
||||
|
||||
createGroup(
|
||||
name: String!
|
||||
): Group
|
||||
|
||||
createTag(
|
||||
name: String!
|
||||
): Tag
|
||||
|
||||
createUser(
|
||||
email: String!
|
||||
name: String
|
||||
passwordRaw: String
|
||||
provider: String!
|
||||
providerId: String
|
||||
role: UserRole!
|
||||
): User
|
||||
|
||||
deleteDocument(
|
||||
id: Int!
|
||||
): OperationResult
|
||||
|
||||
deleteFolder(
|
||||
id: Int!
|
||||
): Boolean
|
||||
): OperationResult
|
||||
|
||||
deleteGroup(
|
||||
id: Int!
|
||||
): Boolean
|
||||
): OperationResult
|
||||
|
||||
deleteTag(
|
||||
id: Int!
|
||||
): Boolean
|
||||
): OperationResult
|
||||
|
||||
deleteUser(
|
||||
id: Int!
|
||||
): Boolean
|
||||
): OperationResult
|
||||
|
||||
modifyDocument(
|
||||
id: Int!
|
||||
title: String
|
||||
subtitle: String
|
||||
): Document
|
||||
|
||||
modifyUser(
|
||||
id: Int!
|
||||
email: String
|
||||
name: String
|
||||
provider: String
|
||||
providerId: String
|
||||
role: UserRole
|
||||
): User
|
||||
|
||||
moveDocument(
|
||||
id: Int!
|
||||
path: String!
|
||||
): OperationResult
|
||||
|
||||
renameFolder(
|
||||
id: Int!
|
||||
name: String!
|
||||
): OperationResult
|
||||
|
||||
renameGroup(
|
||||
id: Int!
|
||||
name: String!
|
||||
): OperationResult
|
||||
|
||||
renameTag(
|
||||
id: Int!
|
||||
name: String!
|
||||
): OperationResult
|
||||
|
||||
removeTagFromDocument(
|
||||
tagId: Int!
|
||||
documentId: Int!
|
||||
): Boolean
|
||||
): OperationResult
|
||||
|
||||
removeUserFromGroup(
|
||||
userId: Int!
|
||||
groupId: Int!
|
||||
): Boolean
|
||||
): OperationResult
|
||||
|
||||
resetUserPassword(
|
||||
id: Int!
|
||||
): OperationResult
|
||||
|
||||
setUserPassword(
|
||||
id: Int!
|
||||
passwordRaw: String!
|
||||
): OperationResult
|
||||
}
|
||||
|
Reference in New Issue
Block a user