So I am creating an application which has some social media aspects to it.
To simplify my question, lets say that every user can have multiple posts and other users can like these posts or comment on those and users can follow each other.
What I want is to have is a Notifications feed which should show on UI something like what twitter does.
When there is a Post from someone I follow I want to see that notification, as well as when someone likes or comments on my post I want to see those notifications.
then there will be system notifications such as reminders or recommendations.
I am using DGraph Cloud (Slash) and UI is directly connected to graphql . I can use lambdas.
What I am not 100% clear is how should I structure the schema and mutations to add these notifications.
So, lets say a user likes a post. Should I add a new notification for the author using lambda mutations?
But then it looks like I will have to create lambda mutations almost everywhere and cannot use the auto generated mutations. Or is there a way to Trigger new mutation from a mutation. Example: when user likes a post, the Backend will go ahead and create a new notification for the author (without lambdas).
Any help is highly appreciated.
EDIT: looks like @ custom could help me. Can I use Custom resolver to call the SAME graph endpoint?
Each of these “methods” will create a new Notification, but are used for different purposes.
And to answer your question: I don’t quite understand the question - are you asking if you can use @custom(url: xxxx.cloud.dgraph.io/graphql ... ) on a field?
yes, regarding the question I am asking to put @custom on field and call the same slash graphql endpoint again.
I get about the Lambdas, but the main question still remains, I want these mutations to fire when there are Other mutations.
Example, when a user likes a post, a new notification mutation is triggered. and I don’t want to do this from the UI.
So then I think what I need is a Lambda mutation for liking a post and within the lambda invoking the notification mutation. But in this way I have to write lambda mutations for almost everything because most of the stuff on site trigger a notification.
It can be done right now with the custom or lambda directive, but it would take a lot of work to make work perfectly and efficiently without a bunch of code duplication for every different kind of notification. What you need is in development.
Why not a subscription to a queue of notifications?
The application guarantees the subscription for this queue and you make triggers that will always send information to it. So every time the user goes online, the app will call the subscription.
If you are talking about a push notification for apps, there are a lot of services that cover this.
Subscriptions are push events, but It doesn’t work the same as push notifications(OS level).
Thanks, I need to read a bit more about this, but I don’t think Subscriptions are what I need because as per my understanding subscriptions are only useful for live updates.
I need the notifications to be stored in the DataBase and available to be retrieved, queried.
What @amaster507 suggested which is in-development feature could help.
Looks like as of now I just have to write lambda mutations for everything OR I would need to introduce an intermediate server which would perform two mutations - one for the actual Data (say, Likes) and second for pushing in the notifications.
You could just go old school and add a queueing system. Like Kafka or rabbitmq. Messaging software was created just for this need and does not fail for the job.