Is it possible to use prisma outside of the resolv...
# orm-help
e
Is it possible to use prisma outside of the resolvers context? Basically, I’m trying to update a Canvas’ data to an arbitrary value every 60 seconds – I have a
node-cron
job for this which starts scheduling on the yoga server start… Sample Job
Copy code
import * as cron from 'node-cron'

import {prisma} from './generated/prisma-client'

let cronCounter: number = 0
const updateData = cron.schedule(
  '*/1 * * * *',
  () => {
    prisma.updateCanvas({
      where: {id: '1'},
      data: {data: `cron data${cronCounter}`},
    })
    cronCounter++
    console.log('cron job: updateData')
  },
  {scheduled: false},
)

export {updateData}
The cron job runs, but the database isn’t actually updated. I assume this is because its not attached to a request from the graphQL server. Is there any way to implement this type of system?
h
It is completely possible, you can even make a rest API using prisma
e
Ah, got it working! Forgot to make the callback async and await the prisma operation. Ty for the response 👍
👍 2