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
1405b822
Commit
1405b822
authored
Aug 13, 2017
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: GraphQL Date scalar
parent
7e1cb3d1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
26 deletions
+50
-26
configure.js
server/configure.js
+5
-5
graphql.js
server/modules/graphql.js
+3
-1
scalar-date.js
server/schemas/scalar-date.js
+22
-0
types.graphql
server/schemas/types.graphql
+20
-20
No files found.
server/configure.js
View file @
1405b822
...
...
@@ -81,9 +81,9 @@ module.exports = (port, spinner) => {
()
=>
{
const
semver
=
require
(
'semver'
)
if
(
!
semver
.
satisfies
(
semver
.
clean
(
process
.
version
),
'>=6.9.0'
))
{
throw
new
Error
(
'Node.js version is too old. Minimum is v6.
6.0
.'
)
throw
new
Error
(
'Node.js version is too old. Minimum is v6.
11.1
.'
)
}
return
'Node.js '
+
process
.
version
+
' detected.
Minimum is v6.9.0.
'
return
'Node.js '
+
process
.
version
+
' detected.'
},
()
=>
{
return
Promise
.
try
(()
=>
{
...
...
@@ -110,10 +110,10 @@ module.exports = (port, spinner) => {
},
()
=>
{
const
os
=
require
(
'os'
)
if
(
os
.
totalmem
()
<
1000
*
1000
*
768
)
{
throw
new
Error
(
'Not enough memory. Minimum is
768
MB.'
)
if
(
os
.
totalmem
()
<
1000
*
1000
*
512
)
{
throw
new
Error
(
'Not enough memory. Minimum is
512
MB.'
)
}
return
_
.
round
(
os
.
totalmem
()
/
(
1024
*
1024
))
+
' MB of system memory available. Minimum is
768
MB.'
return
_
.
round
(
os
.
totalmem
()
/
(
1024
*
1024
))
+
' MB of system memory available. Minimum is
512
MB.'
},
()
=>
{
let
fs
=
require
(
'fs'
)
...
...
server/modules/graphql.js
View file @
1405b822
...
...
@@ -9,12 +9,14 @@ const _ = require('lodash')
const
typeDefs
=
fs
.
readFileSync
(
path
.
join
(
wiki
.
SERVERPATH
,
'schemas/types.graphql'
),
'utf8'
)
const
DateScalar
=
require
(
'../schemas/scalar-date'
)
const
GroupResolvers
=
require
(
'../schemas/resolvers-group'
)
const
UserResolvers
=
require
(
'../schemas/resolvers-user'
)
const
resolvers
=
_
.
merge
(
GroupResolvers
,
UserResolvers
UserResolvers
,
DateScalar
)
const
Schema
=
gqlTools
.
makeExecutableSchema
({
...
...
server/schemas/scalar-date.js
0 → 100644
View file @
1405b822
'use strict'
const
gql
=
require
(
'graphql'
)
module
.
exports
=
{
Date
:
new
gql
.
GraphQLScalarType
({
name
:
'Date'
,
description
:
'ISO date-time string at UTC'
,
parseValue
(
value
)
{
return
new
Date
(
value
)
},
serialize
(
value
)
{
return
value
.
toISOString
()
},
parseLiteral
(
ast
)
{
if
(
ast
.
kind
!==
gql
.
Kind
.
STRING
)
{
throw
new
TypeError
(
'Date value must be an string!'
)
}
return
new
Date
(
ast
.
value
)
}
})
}
server/schemas/types.graphql
View file @
1405b822
...
...
@@ -25,16 +25,16 @@ enum RightRole {
interface
Base
{
id
:
Int
!
created
On
:
Date
updated
On
:
Date
created
At
:
Date
updated
At
:
Date
}
# TYPES
type
Comment
implements
Base
{
id
:
Int
!
created
On
:
Date
updated
On
:
Date
created
At
:
Date
updated
At
:
Date
content
:
String
document
:
Document
!
author
:
User
!
...
...
@@ -42,8 +42,8 @@ type Comment implements Base {
type
Document
implements
Base
{
id
:
Int
!
created
On
:
Date
updated
On
:
Date
created
At
:
Date
updated
At
:
Date
path
:
String
!
title
:
String
!
subtitle
:
String
...
...
@@ -57,8 +57,8 @@ type Document implements Base {
type
File
implements
Base
{
id
:
Int
!
created
On
:
Date
updated
On
:
Date
created
At
:
Date
updated
At
:
Date
category
:
FileType
!
mime
:
String
!
extra
:
String
...
...
@@ -70,15 +70,15 @@ type File implements Base {
type
Folder
implements
Base
{
id
:
Int
!
created
On
:
Date
updated
On
:
Date
created
At
:
Date
updated
At
:
Date
name
:
String
!
}
type
Group
implements
Base
{
id
:
Int
!
created
On
:
Date
updated
On
:
Date
created
At
:
Date
updated
At
:
Date
name
:
String
!
users
:
[
User
]
rights
:
[
Right
]
...
...
@@ -86,8 +86,8 @@ type Group implements Base {
type
Right
implements
Base
{
id
:
Int
!
created
On
:
Date
updated
On
:
Date
created
At
:
Date
updated
At
:
Date
path
:
String
!
role
:
RightRole
!
exact
:
Boolean
!
...
...
@@ -96,8 +96,8 @@ type Right implements Base {
type
Setting
implements
Base
{
id
:
Int
!
created
On
:
Date
updated
On
:
Date
created
At
:
Date
updated
At
:
Date
key
:
String
!
config
:
String
!
}
...
...
@@ -105,16 +105,16 @@ type Setting implements Base {
# Tags are attached to one or more documents
type
Tag
implements
Base
{
id
:
Int
!
created
On
:
Date
updated
On
:
Date
created
At
:
Date
updated
At
:
Date
key
:
String
!
}
# A User
type
User
implements
Base
{
id
:
Int
!
created
On
:
Date
updated
On
:
Date
created
At
:
Date
updated
At
:
Date
email
:
String
!
provider
:
String
!
providerId
:
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