graphql#GraphQLScalarType JavaScript Examples
The following examples show how to use
graphql#GraphQLScalarType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: phone.js From Spoke with MIT License | 6 votes |
GraphQLPhone = new GraphQLScalarType({
name: "Phone",
description: "Phone number",
parseValue: identity,
serialize: identity,
parseLiteral(ast) {
if (ast.kind !== Kind.STRING) {
throw new GraphQLError(
`Query error: Can only parse strings got a: ${ast.kind}`,
[ast]
);
}
if (!pattern.test(ast.value)) {
throw new GraphQLError("Query error: Not a valid Phone", [ast]);
}
return ast.value;
}
})
Example #2
Source File: DateTime.js From rate-repository-api with MIT License | 5 votes |
resolvers = {
DateTime: new GraphQLScalarType(config),
}