Hey, just getting started. If I have types A and ...
# prisma-whats-new
a
Hey, just getting started. If I have types A and B and A has many Bs, but B has no relation to A. How do I accomplish that? A relation seems wrong as that seemingly creates fields on B. I feel like I'm missing something obvious.
a
Relations are always created on both Types, so if A has many B's, B is going to have an A.
a
I'm trying to port over an existing rest API. There is an array which has
{name: "", url: ""}
which is how they relate it to another type. However, in this case, B has no As. It sounds like I have to define a Many to Many relationship since A has many Bs and any A could reference any B with overlap.
a
Or, if you don't need to query the name and url fields of B directly, you could create a field of Type [Json] on A to store the information
a
Oh now that is and idea... cool thanks! 👍 It's not gonna be a fun time getting this data over but I'd rather manage it here than create a ton of Schema Extensions.
a
In that case, you can query:
Copy code
query {
  allAs {
    B
  }
}
But you cannot query:
Copy code
query {
  allAs {
    B {
      url
      name
    }
  }
}
a
I understand, I plan on doing more post processing to the data based on this so I think that'll workout okay for me.
👍🏻 1