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 AMweakky
06/07/2018, 10:02 AMArnab
06/07/2018, 10:03 AMArnab
06/07/2018, 10:04 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 AMweakky
06/07/2018, 10:25 AMArnab
06/07/2018, 10:26 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 AMhuv1k
06/07/2018, 10:35 AM{
products(shopName:"Prisma") {
name
}
}Arnab
06/07/2018, 10:36 AMArnab
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 AMweakky
06/07/2018, 11:01 AMweakky
06/07/2018, 11:53 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 createMutationsweakky
06/07/2018, 11:57 AMwhere: { shop: { id: shopId } } to every queries. c&p’ed everywhere and done.Arnab
06/07/2018, 11:57 AMArnab
06/07/2018, 11:58 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 ?weakky
06/08/2018, 8:22 AMorders 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 AMArnab
06/08/2018, 8:27 AMArnab
06/08/2018, 8:28 AMweakky
06/08/2018, 8:28 AMweakky
06/08/2018, 8:28 AMme resolver (parent of orders), then I have to provide a custom infoweakky
06/08/2018, 8:30 AMctx.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.weakky
06/08/2018, 8:34 AMShop without ever being changed, are their orders.weakky
06/08/2018, 8:40 AMShop, 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 😞weakky
06/08/2018, 11:08 AMorders sub-field of the model User