Prisma1: Many to many self-relations is a one way connection

Created on 5 Apr 2018  路  3Comments  路  Source: prisma/prisma1

Bug Report

Current behavior

If we connect many to many self relation from A to B, we will get A related to B, but B is not related to A.

Reproduction

Database Shema

type Post {
  id: ID! @unique
  related: [Post!]! @relation(name: "RelatedPosts")
}

For example we have 2 post A with id cjbz2h6eej5gf0113ow5par0d and and post B with id cjda754u0vlfu01850l4hw31t. Now let connect them together

mutation {
  updatePost (
    id: "cjbz2h6eej5gf0113ow5par0d"
    data: {
      related: {
        connect: {
          id: "cjda754u0vlfu01850l4hw31t"
        }
      }
    }
  ) {
    id
    related {
      id
    }
  }
}

the result

{
  "data": {
    "updatePost": {
      "id": "cjbz2h6eej5gf0113ow5par0d",
      "related": [
        {
          "id": "cjda754u0vlfu01850l4hw31t"
        }
      ]
    }
  }
}

Query A we have

{
  "data": {
    "movie": {
      "id": "cjbz2h6eej5gf0113ow5par0d",
      "related": [
        {
          "id": "cjda754u0vlfu01850l4hw31t"
        }
      ]
    }
  }
}

Query B we have

{
  "data": {
    "movie": {
      "id": "cjda754u0vlfu01850l4hw31t",
      "related": []
    }
  }
}

Expected behavior?

B should have A in related field

{
  "data": {
    "movie": {
      "id": "cjda754u0vlfu01850l4hw31t",
      "related": [
        {
          "id": "cjbz2h6eej5gf0113ow5par0d"
        }
      ]
    }
  }
}
bu2-confirmed areapi

All 3 comments

What is your prisma version and your prisma cluster list?

I use prisma 1.5.1

The cluster I use is prisma-us1 1.5.1

Hey @kieusonlam thanks for reporting this. I can reproduce it. It looks like the relation data is correctly being created, but we resolve it incorrectly during the query.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MitkoTschimev picture MitkoTschimev  路  3Comments

notrab picture notrab  路  3Comments

schickling picture schickling  路  3Comments

schickling picture schickling  路  3Comments

ragnorc picture ragnorc  路  3Comments