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
7e1cb3d1
Commit
7e1cb3d1
authored
Aug 08, 2017
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: GraphQL mutations for User + Group
parent
e0b78850
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
18 deletions
+58
-18
graphql.js
server/modules/graphql.js
+5
-8
resolvers-group.js
server/schemas/resolvers-group.js
+10
-3
resolvers-user.js
server/schemas/resolvers-user.js
+10
-3
types.graphql
server/schemas/types.graphql
+32
-3
fuse.js
tools/fuse.js
+1
-1
No files found.
server/modules/graphql.js
View file @
7e1cb3d1
...
...
@@ -5,20 +5,17 @@
const
gqlTools
=
require
(
'graphql-tools'
)
const
fs
=
require
(
'fs'
)
const
path
=
require
(
'path'
)
const
_
=
require
(
'lodash'
)
const
typeDefs
=
fs
.
readFileSync
(
path
.
join
(
wiki
.
SERVERPATH
,
'schemas/types.graphql'
),
'utf8'
)
const
GroupResolvers
=
require
(
'../schemas/resolvers-group'
)
const
UserResolvers
=
require
(
'../schemas/resolvers-user'
)
const
resolvers
=
{
Query
:
{
groups
:
GroupResolvers
.
Query
,
users
:
UserResolvers
.
Query
},
Group
:
GroupResolvers
.
Type
,
User
:
UserResolvers
.
Type
}
const
resolvers
=
_
.
merge
(
GroupResolvers
,
UserResolvers
)
const
Schema
=
gqlTools
.
makeExecutableSchema
({
typeDefs
,
...
...
server/schemas/resolvers-group.js
View file @
7e1cb3d1
...
...
@@ -3,10 +3,17 @@
/* global wiki */
module
.
exports
=
{
Query
(
obj
,
args
,
context
,
info
)
{
return
wiki
.
db
.
Group
.
findAll
({
where
:
args
})
Query
:
{
groups
(
obj
,
args
,
context
,
info
)
{
return
wiki
.
db
.
Group
.
findAll
({
where
:
args
})
}
},
Mutation
:
{
createGroup
(
obj
,
args
)
{
return
wiki
.
db
.
Group
.
create
(
args
)
}
},
Type
:
{
Group
:
{
users
(
grp
)
{
return
grp
.
getUsers
()
}
...
...
server/schemas/resolvers-user.js
View file @
7e1cb3d1
...
...
@@ -3,10 +3,17 @@
/* global wiki */
module
.
exports
=
{
Query
(
obj
,
args
,
context
,
info
)
{
return
wiki
.
db
.
User
.
findAll
({
where
:
args
})
Query
:
{
users
(
obj
,
args
,
context
,
info
)
{
return
wiki
.
db
.
User
.
findAll
({
where
:
args
})
}
},
Mutation
:
{
createUser
(
obj
,
args
)
{
return
wiki
.
db
.
User
.
create
(
args
)
}
},
Type
:
{
User
:
{
groups
(
usr
)
{
return
usr
.
getGroups
()
}
...
...
server/schemas/types.graphql
View file @
7e1cb3d1
...
...
@@ -102,6 +102,7 @@ type Setting implements Base {
config
:
String
!
}
# Tags are attached to one or more documents
type
Tag
implements
Base
{
id
:
Int
!
createdOn
:
Date
...
...
@@ -109,20 +110,20 @@ type Tag implements Base {
key
:
String
!
}
# A User
type
User
implements
Base
{
id
:
Int
!
createdOn
:
Date
updatedOn
:
Date
email
:
String
!
provider
:
String
provider
:
String
!
providerId
:
String
name
:
String
role
:
UserRole
!
groups
:
[
Group
]
}
# QUERY
# Query (Read)
type
Query
{
comments
(
id
:
Int
):
[
Comment
]
documents
(
id
:
Int
,
path
:
String
):
[
Document
]
...
...
@@ -134,3 +135,31 @@ type Query {
tags
(
key
:
String
):
[
Tag
]
users
(
id
:
Int
,
email
:
String
,
provider
:
String
,
providerId
:
String
,
role
:
UserRole
):
[
User
]
}
# Mutations (Create, Update, Delete)
type
Mutation
{
assignUserToGroup
(
userId
:
Int
!
groupId
:
Int
!
):
Boolean
createGroup
(
name
:
String
!
):
Group
createUser
(
email
:
String
!
name
:
String
provider
:
String
!
providerId
:
String
role
:
UserRole
!
):
User
deleteGroup
(
id
:
Int
!
):
Boolean
deleteUser
(
id
:
Int
!
):
Boolean
removeUserFromGroup
(
userId
:
Int
!
groupId
:
Int
!
):
Boolean
}
tools/fuse.js
View file @
7e1cb3d1
...
...
@@ -140,7 +140,7 @@ globalTasks.then(() => {
nodemon
({
exec
:
(
args
.
d
)
?
'node server'
:
'node wiki configure'
,
ignore
:
[
'assets/'
,
'client/'
,
'data/'
,
'repo/'
,
'tests/'
],
ext
:
'js json'
,
ext
:
'js json
graphql
'
,
watch
:
(
args
.
d
)
?
[
'server'
]
:
[
'server/configure.js'
],
env
:
{
'NODE_ENV'
:
'development'
}
})
...
...
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