prisma1 icon indicating copy to clipboard operation
prisma1 copied to clipboard

Two fields with the same Embed throws an error

Open rollthecoder opened this issue 7 years ago • 2 comments

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")`		

rollthecoder avatar May 08 '19 22:05 rollthecoder

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.

SergeiMeza avatar May 11 '19 05:05 SergeiMeza

Is this a bug or feature ? :(

byteab avatar Oct 23 '19 11:10 byteab