If I am passing an ID of a type to a different typ...
# orm-help
i
If I am passing an ID of a type to a different type and storing it as a value on one of its fields through the front end- is there a way to create a relationship in the backend between these two types? Or is it not possible because I am passing the The id from the front end
j
decorate it as a relation in your
Copy code
datamodel.prisma
and it will create it for you if we're talking Prisma! 🙂
Here's an example 🙂
Copy code
author: User! @relation(name: "PostToUser", onDelete: SET_NULL)
i
Thank you
🙂 1
hmm but if I do that, how do I reference that field in the schema.graphql.... for example
parent: String
.... does not work because in the datamodel.prisma I made that field
parent: Collection! @relation(name: "CollectionItemBelongsIn", onDelete: SET_NULL)
So in the
schema.graphql
I need to reference that field somehow since its going to be passed in through the front end but the issue is that now through that relationship I cannot just add parent:String since its not set to be a string in datamodel.prisma now since we set it to a relation