Created
July 8, 2017 08:54
-
-
Save chenminhua/dc058f5e678b99038d32e16dca5e6565 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const DateType = new GraphQLScalarType({ | |
name: 'DateType', | |
description: '自定义时间类型', | |
parseValue: String, | |
serialize(value) { | |
return value.toString(); | |
}, | |
parseLiteral(ast) { | |
if (!moment(ast.value).isValid()) { | |
throw new GcBaseError('非法时间'); | |
} | |
return ast ? ast.value : null; | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment