Skip to content

Instantly share code, notes, and snippets.

@chenminhua
Created July 8, 2017 08:54
Show Gist options
  • Save chenminhua/dc058f5e678b99038d32e16dca5e6565 to your computer and use it in GitHub Desktop.
Save chenminhua/dc058f5e678b99038d32e16dca5e6565 to your computer and use it in GitHub Desktop.
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