question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support 2018-06-29T03:14:59.085+0000

See original GitHub issue

It can be recognized by new Date(), but I have to add resolver for DateTime:

  createdAt({ createdAt }) {
    return new Date(createdAt);
  },

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
linonetwocommented, Feb 9, 2019

@alewiahmed Hi, I actually fork the code here and modify it:

/* eslint-disable eqeqeq */
// @flow
import { GraphQLScalarType, Kind } from 'graphql';
import type { GraphQLScalarTypeConfig } from 'graphql'; // eslint-disable-line

const config: GraphQLScalarTypeConfig<Date, string> = {
  name: 'DateTime',
  description:
    'A date-time string at UTC, such as 2007-12-03T10:15:30Z, ' +
    'compliant with the `date-time` format outlined in section 5.6 of ' +
    'the RFC 3339 profile of the ISO 8601 standard for representation ' +
    'of dates and times using the Gregorian calendar.',
  serialize(value) {
    const date = new Date(value);
    if (date == 'Invalid Date') {
      throw new TypeError(
        `${'DateTime cannot be serialized from a non string, non numeric or non Date type '}${JSON.stringify(
          value,
        )}`,
      );
    }
    return date.toISOString();
  },
  parseValue(value) {
    if (!(typeof value === 'string' || value instanceof String)) {
      throw new TypeError(`DateTime cannot represent non string type ${JSON.stringify(value)}`);
    }

    const date = new Date(value);
    if (date == 'Invalid Date') {
      throw new TypeError(`DateTime cannot represent an invalid date-time-string ${value}.`);
    }
    return date;
  },
  parseLiteral(ast) {
    if (ast.kind !== Kind.STRING) {
      throw new TypeError(`DateTime cannot represent non string type ${String(ast.value != null ? ast.value : null)}`);
    }
    const { value } = ast;
    const date = new Date(value);
    if (date == 'Invalid Date') {
      throw new TypeError(`DateTime cannot represent an invalid date-time-string ${String(value)}.`);
    }
    return date;
  },
};

export default new GraphQLScalarType(config);

1reaction
linonetwocommented, Jun 29, 2018

And how about 2018-06-27T10:51:44.000 ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found