weakky
06/07/2018, 9:46 AMShop
model that would have it’s own products/orders/customers etc, etc (like Shopify is doing)), or to split all shops into their own prisma/db, and when the user choose his shop (on sign-in), store a link on the User
model that would contain let’s say the graphql-endpoint of the chosen shop ?kuldar
06/07/2018, 9:55 AMweakky
06/07/2018, 9:58 AMArnab
06/07/2018, 10:03 AMweakky
06/07/2018, 10:06 AMArnab
06/07/2018, 10:06 AMweakky
06/07/2018, 10:09 AMShop
model, and then linking every Users to a Shop. I need to investigate though what will happen when users will want to switch from one shop to another 😕Arnab
06/07/2018, 10:23 AMweakky
06/07/2018, 10:24 AMArnab
06/07/2018, 10:26 AMweakky
06/07/2018, 10:28 AMShop
model. Otherwise that means once a user will wanna switch from one shop to another, I would have to migrate all its datahuv1k
06/07/2018, 10:34 AM{
products(shopName:"Prisma") {
name
}
}
Arnab
06/07/2018, 10:36 AMshopName
set somewhere and you use that to determine what data they get. The advantage being that they can't just do a random query on a shop they shouldn't be able to accessweakky
06/07/2018, 11:01 AMshopId
. Not entirely sure if everything’s safe yet, but refacto done, in 20mn, as I have nothing to change anywhere in my apps 😍Arnab
06/07/2018, 11:54 AMweakky
06/07/2018, 11:56 AMconnect: { shop: { id: shopId }
to every createMutations
where: { shop: { id: shopId } }
to every queries. c&p’ed everywhere and done.Arnab
06/07/2018, 11:57 AMweakky
06/07/2018, 12:00 PMArnab
06/07/2018, 1:20 PMweakky
06/08/2018, 8:18 AMUser
is linked to a model Order
. When the user fetches his orders, me { id, orders { id ... } }
, I’d like to grab only the orders made on one Shop
without having to pass a shopId
everytime to my queries. Is it possible this way ?orders
field of the parent field me
, but I’m not sure how to do that.huv1k
06/08/2018, 8:25 AMweakky
06/08/2018, 8:26 AMShop
, so I can grab their shopId
by querying ctx.db.query.user({ where: { id: userId } }, ' { shop { id } } ')
.Arnab
06/08/2018, 8:27 AMweakky
06/08/2018, 8:28 AMme
resolver (parent of orders
), then I have to provide a custom info
ctx.db.query.user({ where: { id: userId }}, '{ orders(where: { shopId: userShopId } ) })
. And I don’t want to do that, otherwise the resolver won’t return what’s queried from the clientshuv1k
06/08/2018, 8:31 AMweakky
06/08/2018, 8:33 AMShop
can be changed. As all my resolvers are contextual, if they wanna switch from one shop to another, I just updateUser
and connect it to another Shop.Shop
without ever being changed, are their orders.Shop
, I look for all users that have at least one order sent to that Shop. The link between a Shop
and a User
could be name selectedShop
. It’s completely changeable and not bounded forever. But because of that, when a user switch from one shop to another, I need to grab ONLY the orders sent to the selectedShop
. Otherwise, as user can add to their cart some of their previous orders, they could potentially add some products that aren’t available on their current selectedShop
. Hopefully I’m being clear, it’s quite tough to explain 😞orders
sub-field of the model User