Hey everyone, I’m struggling with something and I ...
# orm-help
j
Hey everyone, I’m struggling with something and I was hoping I could get some direction. If my user creates a post, I’d like them to be able to schedule it to publish at a certain time. I’m using the
node-schedule
library to do this, which acts like a Node cron job. I want query to run at midnight every day that will check all the pending posts, see if the
DateTime
matches the current day, and then confirm the post. My question is, how can I run this query on the server? Obviously doing it on the front-end is easy enough, but running these queries on the server is proving challenging, since all the examples with Prisma and it’s resolvers rely on the
ctx
object and such. I cannot find any documentation for this in `graphql-yoga`’s README or anywhere else. Does anyone have a quick answer to this?
p
when you say the “server” do you mean the prisma server itself or the graphql server sitting between it and the frontend? you could have a scheduled task query your prisma server directly via
prisma-bindings
or the new
prisma-client
j
Looking into
prisma-binding
turned out to be the solution, thanks!I had to separate out the Prisma server from the graphql server, then I could access everything I needed.
👍 1