prisma1
prisma1 copied to clipboard
Two fields with the same Embed throws an error
Hello, I would like to have two colums with the same type of data
from and to
this is a very simple example about the error
datamodel.prisma file with a one columns from: Address!
// it runs fine
type Travel {
id: ID! @id
from: Address!
}
type Address @embedded {
district: String!
}
datamodel.prisma file with two field with the same embedded from: Address! to: Address!
// it runs fine
type Travel {
id: ID! @id
from: Address!
to: Address! # It have the same Address embedded
}
type Address @embedded {
district: String!
}
when run prisma deploy
It throws the error
Errors:
Travel
✖ The relation field `from` must specify a `@relation` directive: `@relation(name: "MyRelation")`
✖ The relation field `to` must specify a `@relation` directive: `@relation(name: "MyRelation")`
You can fix it like this:
type Travel {
id: ID! @id
from: Address! @relation(name: "FromAddress")
to: Address! @relation(name: "ToAddress")
}
type Address @embedded {
district: String!
}
You use the same relation name when you want to specify friend relationships by example.
Is this a bug or feature ? :(