From 02183f82ecc783d79ed88bd20af16394ca0cad4f Mon Sep 17 00:00:00 2001 From: NGPixel Date: Fri, 18 Aug 2017 21:21:29 -0400 Subject: [PATCH] feat: mutations + updated deps --- package.json | 34 +++++----- server/modules/graphql.js | 2 + server/schemas/resolvers-document.js | 29 +++++++++ server/schemas/types.graphql | 89 ++++++++++++++++++++++++--- yarn.lock | Bin 265702 -> 271011 bytes 5 files changed, 128 insertions(+), 26 deletions(-) create mode 100644 server/schemas/resolvers-document.js diff --git a/package.json b/package.json index 58238db4..d3ed5237 100644 --- a/package.json +++ b/package.json @@ -37,13 +37,13 @@ "node": ">=6.11.1" }, "dependencies": { - "apollo-server-express": "1.0.5", + "apollo-server-express": "1.1.0", "auto-load": "3.0.0", "axios": "0.16.2", "bcryptjs-then": "1.0.1", "bluebird": "3.5.0", "body-parser": "1.17.2", - "bull": "3.0.0-rc.4", + "bull": "3.0.0-rc.7", "bunyan": "1.8.12", "cheerio": "1.0.0-rc.2", "child-process-promise": "2.2.1", @@ -58,23 +58,23 @@ "express-brute": "1.0.1", "express-brute-redis": "0.0.1", "express-session": "1.15.5", - "file-type": "5.2.0", + "file-type": "6.1.0", "filesize.js": "1.0.2", "follow-redirects": "1.2.4", "fs-extra": "4.0.1", "git-wrapper2-promise": "0.2.9", "graphql": "0.10.5", - "graphql-tools": "1.1.0", + "graphql-tools": "1.2.1", "highlight.js": "9.12.0", "i18next": "8.4.3", "i18next-express-middleware": "1.0.5", "i18next-node-fs-backend": "1.0.0", "image-size": "0.6.1", - "ioredis": "3.1.2", + "ioredis": "3.1.4", "jimp": "0.2.28", "js-yaml": "3.9.1", - "jsonwebtoken": "7.4.2", - "klaw": "2.0.0", + "jsonwebtoken": "7.4.3", + "klaw": "2.1.0", "levelup": "1.3.9", "lodash": "4.17.4", "markdown-it": "8.3.2", @@ -87,7 +87,7 @@ "markdown-it-footnote": "3.0.1", "markdown-it-mathjax": "2.0.0", "markdown-it-task-lists": "2.0.1", - "mathjax-node": "1.1.0", + "mathjax-node": "1.1.1", "memdown": "1.2.4", "mime-types": "2.1.16", "moment": "2.18.1", @@ -96,7 +96,7 @@ "node-2fa": "1.1.2", "node-graceful": "0.2.3", "ora": "1.3.0", - "passport": "0.3.2", + "passport": "0.4.0", "passport-azure-ad-oauth2": "0.0.4", "passport-facebook": "2.1.1", "passport-github2": "0.1.10", @@ -106,24 +106,24 @@ "passport-slack": "0.0.7", "passport-windowslive": "1.0.2", "passport.socketio": "3.7.0", - "pg": "7.1.0", + "pg": "7.1.2", "pg-hstore": "2.3.2", - "pg-promise": "6.3.7", + "pg-promise": "6.5.0", "pm2": "2.6.1", "pug": "2.0.0-rc.3", "read-chunk": "2.1.0", - "remove-markdown": "0.2.1", + "remove-markdown": "0.2.2", "request": "2.81.0", "search-index-adder": "0.3.9", "search-index-searcher": "0.2.10", "semver": "5.4.1", - "sequelize": "4.4.2", + "sequelize": "4.5.0", "serve-favicon": "2.4.3", "simplemde": "1.11.2", "socket.io": "2.0.3", "stopword": "0.1.6", "stream-to-promise": "2.2.0", - "tar": "3.1.9", + "tar": "4.0.0", "through2": "2.0.3", "validator": "8.0.0", "validator-as-promised": "1.0.2", @@ -133,7 +133,7 @@ "devDependencies": { "@glimpse/glimpse": "0.22.15", "@panter/vue-i18next": "0.5.1", - "babel-cli": "6.24.1", + "babel-cli": "6.26.0", "babel-jest": "20.0.3", "babel-plugin-transform-object-assign": "6.22.0", "babel-preset-es2015": "6.24.1", @@ -146,7 +146,7 @@ "eslint-plugin-node": "5.1.1", "eslint-plugin-promise": "3.5.0", "eslint-plugin-standard": "3.0.1", - "fuse-box": "2.2.1", + "fuse-box": "2.2.2", "i18next-xhr-backend": "1.4.2", "jest": "20.0.4", "jquery": "3.2.1", @@ -162,7 +162,7 @@ "twemoji-awesome": "1.0.6", "typescript": "2.4.2", "uglify-es": "3.0.27", - "vee-validate": "2.0.0-rc.9", + "vee-validate": "2.0.0-rc.13", "vue": "2.4.2", "vue-clipboards": "1.1.0", "vue-lodash": "1.0.3", diff --git a/server/modules/graphql.js b/server/modules/graphql.js index c3100774..58304fd4 100644 --- a/server/modules/graphql.js +++ b/server/modules/graphql.js @@ -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, diff --git a/server/schemas/resolvers-document.js b/server/schemas/resolvers-document.js new file mode 100644 index 00000000..59963ace --- /dev/null +++ b/server/schemas/resolvers-document.js @@ -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() + } + } +} diff --git a/server/schemas/types.graphql b/server/schemas/types.graphql index 9b347058..9518dc5a 100644 --- a/server/schemas/types.graphql +++ b/server/schemas/types.graphql @@ -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 } diff --git a/yarn.lock b/yarn.lock index 1cd1121b21d5109661a55319882c00a9edd27d80..8420b74583ae66b858c07687e4da328dc22f1c19 100644 GIT binary patch delta 5931 zcmai23y>Ved9In!-AO0(Jl#_|bP|RL*xl>yndzP}AkIPvAtCcHwgD>#Jv}|AgVXKm zc8?&EV98Lij3x0HOvgz8gPoL#6Bl7aCU&TRQlTmYNFXFms%#QbWfPl6kcz@Uk=XfW zckhJ_=u~?*kL~~OzrX+czyE*b4_AKksg;jBw>bTA$Ey0fi;r6M2RiR=H(x&HY_9*# zs!JCwDOM(?$Hpf|M$I?2J6qBfJxg}AZVeZQr7BNN7Ijs$ZWU>XmPDyGcJpZo)0!qO zV}T5b)-tBd^OI0UG-OOiObZ&jE|1bDx}U3mrgxWJf4u+ImFCB7)|&K@#|!BzXPq@n zOQf-u@RS=Ro*R0adRl5BBTgb3hhZpP(codpdeRglZtdu7v%Ej80RO6FlLmNj4 zRuLOJJJT1=?zTn@-C%9O>dVvrI(y@+1uuww!bIdz9tO${xb~>85*o0Od5TF9#*%o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