Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { isRFC3339 } from 'validator';
- import { GraphQLScalarType } from 'graphql';
- export default new GraphQLScalarType({
- name: 'Timestamp',
- description: 'RFC3339 Timestamp format',
- serialize(value) {
- if (isRFC3339(value)) {
- return value;
- }
- throw new Error('Timestamp cannot represent an invalid RFC-3339 Timestamp string');
- },
- parseValue(value) {
- if (isRFC3339(value)) {
- return value;
- }
- throw new Error('Timestamp cannot represent an invalid RFC-3339 Timestamp string');
- },
- parseLiteral(ast) {
- if (isRFC3339(ast.value)) {
- return ast.value;
- }
- throw new Error('Timestamp cannot represent an invalid RFC-3339 Timestamp string');
- }
- });
- scalar Timestamp
- import timeStamp from './scalars/timeStamp';
- .
- .
- .
- .
- const schema = {
- typeDefs: [
- myTypeDefs
- ],
- resolvers: merge(
- resolvers,
- timeStamp
- ),
- };
- export default makeExecutableSchema({
- typeDefs: schema.typeDefs,
- resolvers: schema.resolvers
- });
- throw new _1.SchemaError(""" + typeName + "" defined in resolvers, but has invalid value "" + resolverValue + "". A resolver's value " +
- ^
- Error: "name" defined in resolvers, but has invalid value "Timestamp". A resolver's value must be of type object or function.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement