Is there a way to use Graphcool to setup a subscri...
# prisma-whats-new
m
Is there a way to use Graphcool to setup a subscription to send Push Notifications to a particular set of people (Users that a part of a Team, for instance?).
n
@maxnachamkin how do you want to trigger this push notification? You can use the functions feature for this kind of task
m
Gotcha. I'm wanting to send push notifications on the creation of a Type (I see a one-signal example in the docs), but also wanting to send them to specific users at different intervals if they haven't completed a task, for instance.
(or if a boolean field is false, rather)
Is there a way to do that within functions?
j
@maxnachamkin you can choose to use the create event from mutation functions, that will allow you to check the payload of the mutation/create and confirm whether to send push and who to
for intervals, could you elaborate? Is it after a create? For that you'd need a query and a cron, however, I don't believe crons are active yet in the function options
still in development @artyom?
m
@jjaybrown98 Gotcha. Yeah, I have the following scenario: -A User belongs to a Team -A Survey belongs to a Team -A User has a series of Votes, that when the operation is complete from the front-end, would get marked "voteComplete" as true I want to create a push notification when: -A new Survey is created -A user hasn't done their Votes, in multiple intervals, until they do For instance, when a survey is created they get a push saying a survey is available. Then the following day, if they haven't filled it out yet, they get another push. Then the next day, if they haven't done it, send them 2 notifications throughout the day, 3 the following day, etc, until they complete. Does that make sense?
j
OK, so in the first instance when a survey is available that can be done using a function on the create mutation of a type
for intervals (daily) you'll need to for the time being, setup a cron using webtask.io (suggestion) and poll your graph api checking against each user for outstanding polls
hopefully 🙏 the awesome guys at graphcool will finalise the cron function type and you'll just be able to use that
m
@jjaybrown98 Awesome. I was looking for something like that. Thank you.
j
no problem
m
Do you know of anywhere where I could learn about linking someone's Device ID to their UserID within the Graphcool API and where I could go to learn to write that cron-job? I'd imagine it's beyond the scope of Graphcool specifically.
j
webtask.io has really good documentation on setting up the cron, in terms of querying graphql they released their own headless client https://github.com/graphcool/graphql-request
device ID assuming this is the one offered by the device for push? you should create a relationship or a field in your user type
that will be set when you request the push uuid from the device
m
Roger that. Appreciate it.