Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. import { isRFC3339 } from 'validator';
  2. import { GraphQLScalarType } from 'graphql';
  3.  
  4. export default new GraphQLScalarType({
  5. name: 'Timestamp',
  6. description: 'RFC3339 Timestamp format',
  7. serialize(value) {
  8. if (isRFC3339(value)) {
  9. return value;
  10. }
  11. throw new Error('Timestamp cannot represent an invalid RFC-3339 Timestamp string');
  12. },
  13. parseValue(value) {
  14. if (isRFC3339(value)) {
  15. return value;
  16. }
  17. throw new Error('Timestamp cannot represent an invalid RFC-3339 Timestamp string');
  18. },
  19. parseLiteral(ast) {
  20. if (isRFC3339(ast.value)) {
  21. return ast.value;
  22. }
  23. throw new Error('Timestamp cannot represent an invalid RFC-3339 Timestamp string');
  24. }
  25. });
  26.  
  27. scalar Timestamp
  28.  
  29. import timeStamp from './scalars/timeStamp';
  30. .
  31. .
  32. .
  33. .
  34. const schema = {
  35. typeDefs: [
  36. myTypeDefs
  37. ],
  38. resolvers: merge(
  39. resolvers,
  40. timeStamp
  41. ),
  42. };
  43.  
  44. export default makeExecutableSchema({
  45. typeDefs: schema.typeDefs,
  46. resolvers: schema.resolvers
  47. });
  48.  
  49. throw new _1.SchemaError(""" + typeName + "" defined in resolvers, but has invalid value "" + resolverValue + "". A resolver's value " +
  50. ^
  51.  
  52. 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