-
-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend prismaWhere
generated Input
#837
Comments
prismaWhere
generated Input
The prisma-utils package is still pretty early in it's development. If you need to customize the fields beyond what's currently possible, you will likely need to create your own input types manually. |
Ok, thanks, I don't need to look any further then! I'll create my own! |
Just ran into this same issue.
The |
Yeah, this makes sense, and I think it could make sense to support additional fields. It's a little tricky because a big part of these helpers is to ensure that the types are compatible with prisma. Additional fields can be pulled out, but if you want to add a field that matches an existing prisma field (but use a custom type) there are 2 options which both seem bad: Either allow you to define any field name as being any type (this would mean losing all type-safety from the prisma schema) or just don't allow you to create custom fields that match properties in your prisma types. The alternative I've been considering is to create a new method that allows you to extend or modify input types after definition. I don't have any API in mind yet for exactly how this would work. There are a couple of other ideas I've been considering that might also help:
// this would likely not be the actual API, but roughly shows the ideas from above
const ThingWhere = t.builder.prismaWhere("Thing", {
fields: {
favorites: {
alias: 'favorite',
type: t.builder.prismaFlatFilter("Boolean", {
op: GraphQLFilterOp.equals,
name: "FavoritedFilter",
}),
}
},
}); I'd be interested in what your ideal API would be:
Another question: If you are customizing the input types already to not match exactly the shape that prisma expects, what benefit are you hoping for from using |
I might also just be attempting to misuse this API. And I am glad they keep compatibility with Prisma, has been helpful on the client side when trying to implement filtering as I was used to with Hasura. In order to mix and match as needed I suppose I should just create use
Again I just might be going about this all the wrong way. I am mainly looking for a way to keep the filters strict to a Prisma objects field where I need it and then allow custom inputs along side. |
How can I change the type of the generated input when I use
builder.prismaWhere
, for example if I want to change (remove or add) a field in the input? Currently I have types issues if I do this, and I have to use exactly the same input type as Prisma.The text was updated successfully, but these errors were encountered: