Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
574e4b97
Commit
574e4b97
authored
Aug 19, 2017
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: GraphQL setting, right, folder resolvers
parent
02183f82
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
232 additions
and
1 deletion
+232
-1
_relations.js
server/models/_relations.js
+2
-0
document.js
server/models/document.js
+5
-0
graphql.js
server/modules/graphql.js
+4
-0
resolvers-comment.js
server/schemas/resolvers-comment.js
+43
-0
resolvers-document.js
server/schemas/resolvers-document.js
+18
-0
resolvers-folder.js
server/schemas/resolvers-folder.js
+7
-0
resolvers-group.js
server/schemas/resolvers-group.js
+7
-0
resolvers-right.js
server/schemas/resolvers-right.js
+54
-0
resolvers-setting.js
server/schemas/resolvers-setting.js
+25
-0
resolvers-tag.js
server/schemas/resolvers-tag.js
+7
-0
resolvers-user.js
server/schemas/resolvers-user.js
+17
-0
types.graphql
server/schemas/types.graphql
+43
-1
No files found.
server/models/_relations.js
View file @
574e4b97
...
...
@@ -7,7 +7,9 @@ module.exports = db => {
db
.
User
.
belongsToMany
(
db
.
Group
,
{
through
:
'userGroups'
})
db
.
Group
.
belongsToMany
(
db
.
User
,
{
through
:
'userGroups'
})
db
.
Group
.
hasMany
(
db
.
Right
)
db
.
Right
.
belongsTo
(
db
.
Group
)
db
.
Document
.
belongsToMany
(
db
.
Tag
,
{
through
:
'documentTags'
})
db
.
Document
.
hasMany
(
db
.
Comment
)
db
.
Tag
.
belongsToMany
(
db
.
Document
,
{
through
:
'documentTags'
})
db
.
File
.
belongsTo
(
db
.
Folder
)
db
.
Folder
.
hasMany
(
db
.
File
)
...
...
server/models/document.js
View file @
574e4b97
...
...
@@ -41,6 +41,11 @@ module.exports = (sequelize, DataTypes) => {
allowNull
:
false
,
defaultValue
:
false
},
isDraft
:
{
type
:
DataTypes
.
BOOLEAN
,
allowNull
:
false
,
defaultValue
:
false
},
searchContent
:
{
type
:
DataTypes
.
TEXT
,
allowNull
:
true
,
...
...
server/modules/graphql.js
View file @
574e4b97
...
...
@@ -10,16 +10,20 @@ const _ = require('lodash')
const
typeDefs
=
fs
.
readFileSync
(
path
.
join
(
wiki
.
SERVERPATH
,
'schemas/types.graphql'
),
'utf8'
)
const
DateScalar
=
require
(
'../schemas/scalar-date'
)
const
CommentResolvers
=
require
(
'../schemas/resolvers-comment'
)
const
DocumentResolvers
=
require
(
'../schemas/resolvers-document'
)
const
FolderResolvers
=
require
(
'../schemas/resolvers-folder'
)
const
GroupResolvers
=
require
(
'../schemas/resolvers-group'
)
const
SettingResolvers
=
require
(
'../schemas/resolvers-setting'
)
const
TagResolvers
=
require
(
'../schemas/resolvers-tag'
)
const
UserResolvers
=
require
(
'../schemas/resolvers-user'
)
const
resolvers
=
_
.
merge
(
CommentResolvers
,
DocumentResolvers
,
FolderResolvers
,
GroupResolvers
,
SettingResolvers
,
TagResolvers
,
UserResolvers
,
DateScalar
...
...
server/schemas/resolvers-comment.js
0 → 100644
View file @
574e4b97
'use strict'
/* global wiki */
module
.
exports
=
{
Query
:
{
comments
(
obj
,
args
,
context
,
info
)
{
return
wiki
.
db
.
Comment
.
findAll
({
where
:
args
})
}
},
Mutation
:
{
createComment
(
obj
,
args
)
{
return
wiki
.
db
.
Comment
.
create
({
content
:
args
.
content
,
author
:
args
.
userId
,
document
:
args
.
documentId
})
},
deleteComment
(
obj
,
args
)
{
return
wiki
.
db
.
Comment
.
destroy
({
where
:
{
id
:
args
.
id
},
limit
:
1
})
},
modifyComment
(
obj
,
args
)
{
return
wiki
.
db
.
Comment
.
update
({
content
:
args
.
content
},
{
where
:
{
id
:
args
.
id
}
})
}
},
Comment
:
{
author
(
cm
)
{
return
cm
.
getAuthor
()
},
document
(
cm
)
{
return
cm
.
getDocument
()
}
}
}
server/schemas/resolvers-document.js
View file @
574e4b97
...
...
@@ -19,9 +19,27 @@ module.exports = {
},
limit
:
1
})
},
modifyDocument
(
obj
,
args
)
{
return
wiki
.
db
.
Document
.
update
({
title
:
args
.
title
,
subtitle
:
args
.
subtitle
},
{
where
:
{
id
:
args
.
id
}
})
},
moveDocument
(
obj
,
args
)
{
return
wiki
.
db
.
Document
.
update
({
path
:
args
.
path
},
{
where
:
{
id
:
args
.
id
}
})
}
},
Document
:
{
comments
(
doc
)
{
return
doc
.
getComments
()
},
tags
(
doc
)
{
return
doc
.
getTags
()
}
...
...
server/schemas/resolvers-folder.js
View file @
574e4b97
...
...
@@ -19,6 +19,13 @@ module.exports = {
},
limit
:
1
})
},
renameFolder
(
obj
,
args
)
{
return
wiki
.
db
.
Folder
.
update
({
name
:
args
.
name
},
{
where
:
{
id
:
args
.
id
}
})
}
},
Folder
:
{
...
...
server/schemas/resolvers-group.js
View file @
574e4b97
...
...
@@ -47,6 +47,13 @@ module.exports = {
return
grp
.
removeUser
(
usr
)
})
})
},
renameGroup
(
obj
,
args
)
{
return
wiki
.
db
.
Group
.
update
({
name
:
args
.
name
},
{
where
:
{
id
:
args
.
id
}
})
}
},
Group
:
{
...
...
server/schemas/resolvers-right.js
0 → 100644
View file @
574e4b97
'use strict'
/* global wiki */
const
gql
=
require
(
'graphql'
)
module
.
exports
=
{
Query
:
{
rights
(
obj
,
args
,
context
,
info
)
{
return
wiki
.
db
.
Right
.
findAll
({
where
:
args
})
}
},
Mutation
:
{
addRightToGroup
(
obj
,
args
)
{
return
wiki
.
db
.
Group
.
findById
(
args
.
groupId
).
then
(
grp
=>
{
if
(
!
grp
)
{
throw
new
gql
.
GraphQLError
(
'Invalid Group ID'
)
}
return
wiki
.
db
.
Right
.
create
({
path
:
args
.
path
,
role
:
args
.
role
,
exact
:
args
.
exact
,
allow
:
args
.
allow
,
group
:
grp
})
})
},
removeRightFromGroup
(
obj
,
args
)
{
return
wiki
.
db
.
Right
.
destroy
({
where
:
{
id
:
args
.
rightId
},
limit
:
1
})
},
modifyRight
(
obj
,
args
)
{
return
wiki
.
db
.
Right
.
update
({
path
:
args
.
path
,
role
:
args
.
role
,
exact
:
args
.
exact
,
allow
:
args
.
allow
},
{
where
:
{
id
:
args
.
id
}
})
}
},
Right
:
{
group
(
rt
)
{
return
rt
.
getGroup
()
}
}
}
server/schemas/resolvers-setting.js
0 → 100644
View file @
574e4b97
'use strict'
/* global wiki */
const
_
=
require
(
'lodash'
)
module
.
exports
=
{
Query
:
{
settings
(
obj
,
args
,
context
,
info
)
{
return
wiki
.
db
.
Setting
.
findAll
({
where
:
args
,
raw
:
true
}).
then
(
entries
=>
{
return
_
.
map
(
entries
,
entry
=>
{
entry
.
config
=
JSON
.
stringify
(
entry
.
config
)
return
entry
})
})
}
},
Mutation
:
{
setConfigEntry
(
obj
,
args
)
{
return
wiki
.
db
.
Setting
.
update
({
value
:
args
.
value
},
{
where
:
{
key
:
args
.
key
}
})
}
}
}
server/schemas/resolvers-tag.js
View file @
574e4b97
...
...
@@ -47,6 +47,13 @@ module.exports = {
return
tag
.
removeDocument
(
doc
)
})
})
},
renameTag
(
obj
,
args
)
{
return
wiki
.
db
.
Group
.
update
({
key
:
args
.
key
},
{
where
:
{
id
:
args
.
id
}
})
}
},
Tag
:
{
...
...
server/schemas/resolvers-user.js
View file @
574e4b97
...
...
@@ -19,6 +19,23 @@ module.exports = {
},
limit
:
1
})
},
modifyUser
(
obj
,
args
)
{
return
wiki
.
db
.
User
.
update
({
email
:
args
.
email
,
name
:
args
.
name
,
provider
:
args
.
provider
,
providerId
:
args
.
providerId
,
role
:
args
.
role
},
{
where
:
{
id
:
args
.
id
}
})
},
resetUserPassword
(
obj
,
args
)
{
return
false
},
setUserPassword
(
obj
,
args
)
{
return
false
}
},
User
:
{
...
...
server/schemas/types.graphql
View file @
574e4b97
...
...
@@ -52,6 +52,7 @@ type Document implements Base {
isDirectory
:
Boolean
!
isEntry
:
Boolean
!
searchContent
:
String
comments
:
[
Comment
]
tags
:
[
Tag
]
}
...
...
@@ -93,6 +94,7 @@ type Right implements Base {
role
:
RightRole
!
exact
:
Boolean
!
allow
:
Boolean
!
group
:
Group
!
}
type
Setting
implements
Base
{
...
...
@@ -145,6 +147,14 @@ type Query {
# Mutations (Create, Update, Delete)
type
Mutation
{
addRightToGroup
(
groupId
:
Int
!
path
:
String
!
role
:
RightRole
!
exact
:
Boolean
!
allow
:
Boolean
!
):
Right
assignTagToDocument
(
tagId
:
Int
!
documentId
:
Int
!
...
...
@@ -155,6 +165,12 @@ type Mutation {
groupId
:
Int
!
):
OperationResult
createComment
(
userId
:
Int
!
documentId
:
Int
!
content
:
String
!
):
Comment
createDocument
(
path
:
String
!
title
:
String
!
...
...
@@ -182,6 +198,10 @@ type Mutation {
role
:
UserRole
!
):
User
deleteComment
(
id
:
Int
!
):
OperationResult
deleteDocument
(
id
:
Int
!
):
OperationResult
...
...
@@ -202,6 +222,11 @@ type Mutation {
id
:
Int
!
):
OperationResult
modifyComment
(
id
:
Int
!
content
:
String
!
):
Document
modifyDocument
(
id
:
Int
!
title
:
String
...
...
@@ -217,6 +242,14 @@ type Mutation {
role
:
UserRole
):
User
modifyRight
(
id
:
Int
!
path
:
String
role
:
RightRole
exact
:
Boolean
allow
:
Boolean
):
Right
moveDocument
(
id
:
Int
!
path
:
String
!
...
...
@@ -234,7 +267,7 @@ type Mutation {
renameTag
(
id
:
Int
!
name
:
String
!
key
:
String
!
):
OperationResult
removeTagFromDocument
(
...
...
@@ -242,6 +275,10 @@ type Mutation {
documentId
:
Int
!
):
OperationResult
removeRightFromGroup
(
rightId
:
Int
!
):
OperationResult
removeUserFromGroup
(
userId
:
Int
!
groupId
:
Int
!
...
...
@@ -251,6 +288,11 @@ type Mutation {
id
:
Int
!
):
OperationResult
setConfigEntry
(
key
:
String
!
value
:
String
!
):
OperationResult
setUserPassword
(
id
:
Int
!
passwordRaw
:
String
!
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment