nexus-plugin-prisma
nexus-plugin-prisma copied to clipboard
Generate WhereInput type and use outside of crud
Is it possible in 2020? I remember that wasn't possible the last time I tried nexus.
I've found nestjs-query that is able to generate such types and used them in custom queries. Would be awesome if nexus could do that as well.
Still waiting for...
It's amazingly already in there, at least I think it is, assuming you want to do something like this:
import {arg} from 'nexus'
t.int("numberOfFibbles", {
args: {
where: arg({ type: "FibbleWhereInput"})
},
async resolve(source, args, context) {
const count = await context.prisma.fibble.count({where: args.where});
return count;
}
})
It seems arg({ type: "FibbleWhereInput"})
will give you access to any type currently in your schema
will give you access to any type currently in your schema
Will, if FibbleWhereInput already registred. It will be only if you call before some like t.crud.fibbles(). This will generate FibbleWhereInput and yes, now you can use it like you said.