feat: GraphQL Date scalar
This commit is contained in:
parent
7e1cb3d171
commit
1405b822f4
@ -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')
|
||||
|
@ -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({
|
||||
|
22
server/schemas/scalar-date.js
Normal file
22
server/schemas/scalar-date.js
Normal file
@ -0,0 +1,22 @@
|
||||
'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)
|
||||
}
|
||||
})
|
||||
}
|
@ -25,16 +25,16 @@ enum RightRole {
|
||||
|
||||
interface Base {
|
||||
id: Int!
|
||||
createdOn: Date
|
||||
updatedOn: Date
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
}
|
||||
|
||||
# TYPES
|
||||
|
||||
type Comment implements Base {
|
||||
id: Int!
|
||||
createdOn: Date
|
||||
updatedOn: Date
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
content: String
|
||||
document: Document!
|
||||
author: User!
|
||||
@ -42,8 +42,8 @@ type Comment implements Base {
|
||||
|
||||
type Document implements Base {
|
||||
id: Int!
|
||||
createdOn: Date
|
||||
updatedOn: Date
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
path: String!
|
||||
title: String!
|
||||
subtitle: String
|
||||
@ -57,8 +57,8 @@ type Document implements Base {
|
||||
|
||||
type File implements Base {
|
||||
id: Int!
|
||||
createdOn: Date
|
||||
updatedOn: Date
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
category: FileType!
|
||||
mime: String!
|
||||
extra: String
|
||||
@ -70,15 +70,15 @@ type File implements Base {
|
||||
|
||||
type Folder implements Base {
|
||||
id: Int!
|
||||
createdOn: Date
|
||||
updatedOn: Date
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
name: String!
|
||||
}
|
||||
|
||||
type Group implements Base {
|
||||
id: Int!
|
||||
createdOn: Date
|
||||
updatedOn: Date
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
name: String!
|
||||
users: [User]
|
||||
rights: [Right]
|
||||
@ -86,8 +86,8 @@ type Group implements Base {
|
||||
|
||||
type Right implements Base {
|
||||
id: Int!
|
||||
createdOn: Date
|
||||
updatedOn: Date
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
path: String!
|
||||
role: RightRole!
|
||||
exact: Boolean!
|
||||
@ -96,8 +96,8 @@ type Right implements Base {
|
||||
|
||||
type Setting implements Base {
|
||||
id: Int!
|
||||
createdOn: Date
|
||||
updatedOn: Date
|
||||
createdAt: Date
|
||||
updatedAt: 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!
|
||||
createdOn: Date
|
||||
updatedOn: Date
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
key: String!
|
||||
}
|
||||
|
||||
# A User
|
||||
type User implements Base {
|
||||
id: Int!
|
||||
createdOn: Date
|
||||
updatedOn: Date
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
email: String!
|
||||
provider: String!
|
||||
providerId: String
|
||||
|
Loading…
Reference in New Issue
Block a user