Replies: 4 comments
-
To go a bit more in depth about a possible solution/work-around I've in mind. I'm going to use TypeORM, so it's going to use an ORM but I don't want to use features that automatically delete the relation data as I'd like to keep control over that. Other modules can hook into this, well... hook, and use the before and after methods to handle specific logic. I can't probably find a way to wrap all this in an injectable provider to keep using the features from GraphQL-Modules and pass the hooks around. And secondly to keep the API simple to use and pass around. And I get to keep my type definitions as All feedback is welcome, thanks! |
Beta Was this translation helpful? Give feedback.
-
You might get more discussion on Discord. https://discord.com/channels/625400653321076807/631489781724872736 😃 Scott |
Beta Was this translation helpful? Give feedback.
-
Thanks, I'll check it out, but the link doesn't work. I don't end up in any channel @smolinari Edit: Ah, I found it through the guild website 👍 |
Beta Was this translation helpful? Give feedback.
-
The approach I would take on this is as follow: chats module: type Chat {
id: Int!
}
mutation {
deleteChat(id: Int!)
} messages module: extend type Chat {
messages: [Message!]!
}
type Message {
content: string!
} now, here comes the trick, on
const resolvers = {
Mutation: {
deleteChat(_, {id}, {injector}) {
// ... delete the chat
// now, this could happen in many ways, on AWS for example I would send an SNS message and have a lambda listening to that
injector.get(PubSub).publish('Chat:Deleted', { id });
}
}
} |
Beta Was this translation helpful? Give feedback.
-
Hello,
I'm thinking about using this library, but I ran into a puzzle that I'm not sure is already solved. Or maybe I'm thinking about it all wrong...
But imagine the following modules:
Chats
andMessages
. In theMessages
module aChat
type is extended so it has messages. The final schema could look like this:Of course in the
Chats
module I write a resolver for thedeleteChat
mutation, but theChats
module doesn't know about theMessages
module. In the resolver I can delete the chat I want to delete, but what's the recommended way to delete the messages that are related to the chat I deleted? Because I want to do this from theMessages
module to keep true modularisation of course.Beta Was this translation helpful? Give feedback.
All reactions