:wave: does anyone know why a Prisma mutation migh...
# orm-help
l
👋 does anyone know why a Prisma mutation might not set a relation on both nodes? I have a simple one-to-one between two types:
Endpoint
and
Organisation
. When I create a new endpoint and connect it to an organisation, I can see the relation to the corresponding organisation on the endpoint. However, when I retrieve the organisation, it does not have an endpoint connected to it. I have plenty of other similar relations with different types and haven't seen this behaviour for those. Any ideas what might be the cause here?
An example:
Copy code
{
  "data": {
    "organisations": [
      {
        "id": "cjhemopj50dxg0720mj3lelo4",
        "endpoint": null
      }
    ]
  }
}
Copy code
{
  "data": {
    "endpoints": [
      {
        "id": "cjhf0gk2g0ehj0720pz7k0kun",
        "organisation": {
          "id": "cjhemopj50dxg0720mj3lelo4"
        }
      }
    ]
  }
}
v
can you share you how looks your datamodel for these fields?
h
I think you forgot connect type from other side
l
A truncated version:
Copy code
type Organisation @model {
  endpoint: Endpoint @relation(name: "EndpointOnOrganisation")
}
Copy code
type Endpoint @model {
  organisation: Organisation! @relation(name: "EndpointOnOrganisation")
}
Ah - I realised the issue! There was a typo on the name of the relation between the two models when I originally deployed. So it wasn't exactly matching. Now that the two names match, it adds the relation to both nodes.
z
you can skip the @relation ... declaration, Prisma automatically creates the name for you
less code = less possibilites for errors
l
oh nice @zonofthor, I didn't know that! thanks 👌