Search code examples
graphqldatamodelprismaprisma-graphql

Prisma datamodel.prisma gives several errors on model


I'm learning to work with GraphQl and prisma and I'm following this tutorial --> https://www.howtographql.com/graphql-js/4-adding-a-database/

I've followed it but changed the Link to a Service that has a name field and a cost(for now this is a string) and I made a datamodel.prisma file that looks like this

type Service {
    id: ID! @id
    createdAt: DataTime! @createdAt
    updatedAt: DataTime! @updatedAt
    name: String!
    cost: String!
}

but it gives me this errors which don't understand it should be the right syntax?:

Errors:

  Service
    × The field `createdAt` has the type `DataTime!` but there's no type or enum declaration with that name.
    × The field `updatedAt` has the type `DataTime!` but there's no type or enum declaration with that name.
    × The relation field `createdAt` must specify a `@relation` directive: `@relation(name: "MyRelation")`
    × The relation field `updatedAt` must specify a `@relation` directive: `@relation(name: "MyRelation")`
    × Fields that are marked as `@createdAt` must be of type `DateTime!` or `DateTime`.    
    × Fields that are marked as @updatedAt must be of type `DateTime!` or `DateTime`.  

I'm not sure why my datamodel is providing these errors could anyone help me with this issue


Solution

  • You have a typo -- it's DateTime, not DataTime.