Hello all, can someone help me with this error in ...
# orm-help
h
Hello all, can someone help me with this error in VS code ? I thought the createdAt & updatedAt are automatically filled
j
It says in the error.
Type 'number' is not assignable to type 'DateTimeInput'
.
Date.now()
returns a number.
It's also maintained by Prisma. You need not fill it. (AFAIK)
h
Thank you @Jenkins,Yeah that was my question, I do understand the error 🙂 if someone can shade the light on why it's giving me the error while Prisma is maintaining the createdAt & updatedAt fields, that would be great
attaching another screenshot with the root cause
@Jenkins it's saying it's missing up here 👆
j
I can see that. Why happens if you pass
new Date(Date.now())
?
Also, that does the type
DateTimeInput
look like in your schema?
h
That is autogenerated
Copy code
/*
DateTime scalar input type, allowing Date
*/
export type DateTimeInput = Date | string;
it works if I did this
Copy code
return ctx.prisma.createPost({
      title,
      content,
      author: {
        connect: { id: userId },
      },
      createdAt: new Date(Date.now()),
      updatedAt: null
    })
but I shouldn't be the one caring about setting those fields, that's my problem
@Moody Saada
m
Shouldn’t Prisma be setting these timestamps for us?
j
In your SDL, is
createdAt
set to
DateTime!
? If it is - remove the
!
. Should make the input nullable.
👍 2
h
ok will test it, but making it nullable might leave it null forever Thanks again @Jenkins I will check and get back if the problem still presists
j
Hey man, no worries! Holla if you need me!
h
unfortunately it's setting the fields with null now after I created the post, I am wondering if there something wrong with my config, btw I forgot to mention that I am using GraphQL nexus
I believe it's a bit different from the prisma code I saw in the tutorial app
j
I've been using graphql nexus as well. Very odd that it's set to null. I'll try and see if I can solve it myself. Will update you if I can.
h
Thanks @Jenkins
j
Aaaah, happy you found the fault!