Is there a recommended way to have prisma client like query functionality by default in all our resolvers, by for example converting info argument to select object accepted by prisma client as in PrismaSelect:
I’m not familiar with Pal.js and “PrismaSelectors”.
What are the benefits to the pattern and how might Redwood use them say in the example tutorial Blog posts services?
For example for structuring a more rich Graphql API like the one questioned in:
For enhancing (used as a middleware or plug-in in yoga server) an already scaffolded posts
resolver that does not only retrieve all the posts using db.posts.findMany()
but also provides all the possible filter arguments used by prisma client.
This is really interesting. Just yesterday I was making up some filters. Eg:
in my SDL
type Query {
transactions(where: TransactionSearchInput): [Transaction!]! @skipAuth
}
input TransactionSearchInput {
transactionType: TransactionType
createdAt: DateTimeFilter
}
input DateTimeFilter {
equals: DateTime
lt: DateTime
lte: DateTime
gt: DateTime
gte: DateTime
not: DateTime
}
And in my service
export const transactions: QueryResolvers['transactions'] = ({ where }) => {
return db.transaction.findMany({
where,
})
}
And while I was figuring it out I was thinking that a computer should have done this for me. Or am I missing a hack like being able to import some standard input types or something like that
Exactly @shansmith01!
To add more contextual information on this, there is a related article (using an older prisma client version in the example) about the info argument in resolvers:
I think this is what the PrismaSelect I mentioned in my initial post takes advantage of. Is there any way to achieve something similar with RedwoodJS?
Another approach to this would be to selectively inject additional Prisma types to *.sdl.ts files (for example [Model]ArgsInput). Is there some easy way to achieve this other than tweaking sdl.ts.template and using the sdl generator? Could we somehow use some of the graphql.d.ts types in our *.sdl.ts?