Reason: 'createdAt' Expected non-null value, found null


#1

Hi!,
I’m having the same issue https://www.prisma.io/forum/t/mutation-error-what-i-this-data/5527, althought I wrote correct field name: createdAt. Here is my datamodel.prisma:

type Link {
  id: ID! @id
  createdAt: DateTime!
  updatedAt: DateTime!
  description: String!
  url: String!
}

My mutation:

mutation {
  post(
    url: "www.prisma.io"
    description: "Prisma replaces traditional ORMs"
  ) {
    id
  }
}

Prisma version: 1.28.0

Error:

{
  "data": null,
  "errors": [
    {
      "message": "Variable '$data' expected value of type 'LinkCreateInput!' but got: {\"url\":\"www.prisma.io\",\"description\":\"Prisma replaces traditional ORMs\"}. Reason: 'createdAt' Expected non-null value, found null. (line 1, column 11):\nmutation ($data: LinkCreateInput!) {\n          ^",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "post"
      ]
    }
  ]
}

Please help me!

Thanks!


#3

Solution.

We need the directives of CreatedAt and UpdatedAt. Here for example in datamodel.prisma:

type User {
  id: ID! @id
  name: String!
  email: String! @unique
  createdAt: DateTime! @createdAt
  updatedAt: DateTime! @updatedAt
}

#4

Thanks for your help! It solved my problem.


#5

You’re welcome. You could mark my answer as solved. So other can see that this thread is solved. Thanks.


#6

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.