I have to add a node to a model at certain interva...
# prisma-whats-new
r
I have to add a node to a model at certain intervals from an external datasource. is it possible without any mutation trigger?
s
Hi @ravikiran Are you able to have something externally trigger this? List a cron job for example
r
Can I observe a model for data changes from nodejs and create a node in the model based on that?
@sorenbs Can I observe a model for data changes from nodejs and create a node in the model based on that?
s
Hey 🙂 When you say
observe a model for data changes
- do you mean observing changes in your Graphcool backend or do you mean changes in some other data store?
If it is changes in Graphcool, there are two options. Either set up a mutation callback or use subscriptions. I haven’t tried using subscriptions from a server, but I don’t see why it wouldn’t work
r
observe(subscribing) from my nodejs server and add a new node to the model depending on changes
s
So you want to add the node to your model in your nodejs server? I’m trying to figure out what way your data is flowing 🙂
r
So you mean subscription would work. Ok I'll give it a try. Any sample code you can provide
No. I have a data source
s
ahh, so when data changes in graphcool you want to update some other database?
r
i want to update graphcool
s
Take a look at this for a thorough subscriptions example https://demo.graph.cool/worldchat
r
simply.. by observing graphcool I want to update graphcool from my nodejs server
s
ok, so a change in graphcool should trigger another update in graphcool?
r
yep...but i don't want to use mutation trigger.
I want my nodejs server to observe it and update accordingly
s
ok - cool 😄 Give subscriptions a go. Will love to hear how well it works running on node
r
sure