Even if I鈥檓 not using a database, Blitz still expects it to be there to use queries.
Create a project
Delete the db directory
Create a query
Output looks like this:
import {rpcHandler} from '@blitzjs/server'
import resolver from 'app/_rpc/queries/scrapeRecipe'
import db from 'db'
export default rpcHandler('query', 'scrapeRecipe', resolver, () => db.connect())
debug: local
debug: pkgPath: /Users/dylan/dev/recipes/node_modules/@blitzjs/cli
macOS Catalina | darwin-x64 | Node: v14.0.0
blitz: 0.11.0 (global)
blitz: 0.11.0 (local)
Ah yeah! This will move into the prisma plugin eventually, but for now we can probably just wrap a try/catch around require(db) and also change to db && db.connect()
Here's where this needs changed: https://github.com/blitz-js/blitz/blob/canary/packages/server/src/synchronizer/pipeline/rules/rpc/index.ts#L68
I'd like to take a stab at this if no one else is working on it!
seems like a good place to get started with contributing 馃槂
Go ahead @MykalMachon! 馃憤