So are the two way relationships that were possilb...
# prisma-whats-new
w
So are the two way relationships that were possilbe in Graphcool doable is prisma?
n
yes for sure!
w
@nilan are there some docs? I have relationships working where User { orders: [Order]! } but what if I want to do it the other way around? Query some orders and then popular the User details for each?
just wondering where/how I define the resolvers for the sub fields
also I think the search is broken on the docs
l
It should work if the inverse relationship is defined, e.g.
Copy code
type User {
  id: ID! @unique
  orders: [Order!]! 
  ...
}
type Order {
   ...
   user: User!
}
Or a many to many if orders can have multiple users
Copy code
users: [Users!]!
w
@lawjolla so when I create an order and set the User, I should be able to just automatically query the Orders property on the User?
l
So long as Order is a root query, yes. e.g.
Copy code
order(where: { id: `stuff`}) {
   orderName
   user {
     name
   }
}
should work
w
Thats the missing piece I didn’t understand - thank you
l
You can import it in your schema.graphql
# import Query.order "./generated/prisma.graphql"
Glad that helped!
w
yah - I knew you could do it, I just didn’t understand how the sub-properties resolved themselves
thanks again
Oh and you can import like that too?
Query.order
?
l
Under the hood it passes the user id through the
parent
into the user resolver
You can
w
greeat
2 for 1
l
💥
w
If anyone is reading this,I can confirm this works 😄 query to test: http://wes.io/pUWo
👍 3