Skip to content

Commit

Permalink
Use Kind from graphql/language instead of magic string: graphql/graph…
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielf committed Aug 2, 2015
1 parent e7afab3 commit 9be2cc8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions datetype.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
GraphQLScalarType,
GraphQLError
} from 'graphql';
import { Kind } from 'graphql/language'

export default new GraphQLScalarType({
name: 'DateTime',
Expand All @@ -16,8 +17,7 @@ export default new GraphQLScalarType({
return value.toJSON()
},
coerceLiteral(ast) {
// Should we import Kind somehow and use Kind.STRING instead of "StringValue"?
if (ast.kind !== "StringValue") {
if (ast.kind !== Kind.STRING ) {
throw new GraphQLError("Query error: Can only parse strings to dates but got a: " + ast.kind, [ast])
}
let result = new Date(ast.value);
Expand Down

0 comments on commit 9be2cc8

Please sign in to comment.