Cannot read property 'toISOString' of null
See original GitHub issueDescription
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:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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
ornull
.I will be making a PR once I have built the site on production to make sure it works.
#527