prisma: Cannot use DateTime, getting error: Provided Json, expected DateTime

Hi I have a following model:

model BpmnProcessInstance {
  dateStarted   DateTime
} 

When trying to create a new record with

await photon.bpmnProcessInstances.create({
      data: {
        dateStarted: new Date(),
      }
})

I am receiving this error:

Argument dateStarted: Got invalid value {} on photon.createOneBpmnProcessInstance. Provided Json, expected DateTime. 

How can I use dates in my app?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (13 by maintainers)

Most upvoted comments

Thanks a lot for looking into this @tomitrescak ! Fixed in latest alpha by https://github.com/prisma/photonjs/pull/285. You can try it out with npm i -g prisma2@alpha.

Hi, this was really blocking me so I found the culprit, which unfortunately is a “bug” in your code. Sometimes the dates get somehow mangled and your condition for if (value instanceof Date) in getGraphQLType function becomes unstable (e.g. when passed across frame boundaries.).

Thus the safest way to test this is to do if (Object.prototype.toString.call(value) === '[object Date]'

After this all worked … I did a PR prisma/photonjs#285