You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The CRUD implementation should expose a way to convert null | undefined to undefined. This would be useful especially for situations where we want to directly pass a where query.
For example, let's say I want to implement a custom resolver for a CRUD query. I can write:
t.crud.myModel({
resolve(root, args, ctx, info) {
const model = ctx.prisma.myModel.findUnique({ where: args.where });
// ... Do something with the result...
return model;
}
})
Currently, this is not possible because of null | undefined incompatibilities. Both value might be received from GQL, but Prisma only allows undefined for fields we wish to ignore in the where query. TypeScript won't compile in strict mode, and I assume that in runtime that might even cause bugs.
At the very least, this function should be easily available for use. Additionally, maybe there should be a flag to have this transform done on inputs before they are pass to our resolver? Another solution would be to allow us to call the original resolver (as a 5th argument to the resolver function), so we can do some pre/post manipulation on the result.
The text was updated successfully, but these errors were encountered:
The CRUD implementation should expose a way to convert
null | undefined
toundefined
. This would be useful especially for situations where we want to directly pass awhere
query.For example, let's say I want to implement a custom resolver for a CRUD query. I can write:
Currently, this is not possible because of
null | undefined
incompatibilities. Both value might be received from GQL, but Prisma only allowsundefined
for fields we wish to ignore in thewhere
query. TypeScript won't compile in strict mode, and I assume that in runtime that might even cause bugs.Internally, the plugin's default resolvers use a custom function to convert
null | undefined
toundefined
: https://github.com/graphql-nexus/nexus-plugin-prisma/blob/6c8801c6e1d99bfdb73a7c1c89db9607712b0e01/src/null.tsAt the very least, this function should be easily available for use. Additionally, maybe there should be a flag to have this transform done on inputs before they are pass to our resolver? Another solution would be to allow us to call the original resolver (as a 5th argument to the resolver function), so we can do some pre/post manipulation on the result.
The text was updated successfully, but these errors were encountered: