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.

Cannot read property 'toISOString' of null

See original GitHub issue

Description

When having date fields that could be set or be null graphql silently fails causing page-query result to be null.

Steps to reproduce

Declare a content type eg. Post with at least two objects containing a field that would be a date, except in the one object set the value of the date field to null. Query for allPost with the date field. You’ll see error from graphql.

Expected result

If the field is null it should just return null instead of trying to convert to date and transforming it.

Actual result

"message": "Cannot read property 'toISOString' of null",
      "stringified": "Cannot read property 'toISOString' of null

Environment


Libs:
- gridsome version: 0.6.4
- @gridsome/cli version: 0.6.4

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
u12206050commented, Jun 30, 2019

I understand what the issue is, it isn’t really the same as yours, since in our case the field always does exist, it is just that the value could be either a valid date or null.

I will be making a PR once I have built the site on production to make sure it works.

0reactions
u12206050commented, Jun 30, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read properties of undefined (reading 'toISOString ...
Looks like either props or props.date is undefined . undefined does not have a method toISOString . Thus calling this function throws an...
Read more >
TypeError: toISOString is not a function in JavaScript
The "toISOString is not a function" error occurs when the toISOString() method is called on a value that is not a date object....
Read more >
JavaScript Date toISOString() Method - W3Schools
The toISOString() method returns a date object as a string, using the ISO standard. The standard is called ISO-8601 and the format is:...
Read more >
[Solved] TypeError: toISOString is not a function - ItsJavaScript
The TypeError: toISOString is not a function occurs if we call a toISOString() method on the object that is not of type Date...
Read more >
How to Avoid the Infamous "Cannot read properties of ... - Bitovi
With TypeScript, there are two ways of interpreting null and undefined types and one of them can avoid the 'Cannot read properties of ......
Read more >

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