Skip to content

Commit

Permalink
Allow prismaFilters to filter for null values with equals, is, and isNot
Browse files Browse the repository at this point in the history
  • Loading branch information
hayes committed Nov 1, 2023
1 parent 3e89a51 commit 8598e34
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/silent-wasps-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@pothos/plugin-prisma-utils': patch
---

Allow filters to set null for equals, is and isNot
4 changes: 3 additions & 1 deletion packages/plugin-prisma-utils/src/schema-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const PrismaStringFilterModeRefMap = new WeakMap<
EnumRef<'default' | 'insensitive'>
>();

const nullableOps = ['equals', 'is', 'isNot'];

schemaBuilder.prismaFilter = function prismaFilter<
Type extends InputType<SchemaTypes>,
Ops extends OpsOptions<SchemaTypes, Type, FilterOps>,
Expand All @@ -70,7 +72,7 @@ schemaBuilder.prismaFilter = function prismaFilter<
...options,
extensions: {
...options.extensions,
pothosPrismaInput: true,
pothosPrismaInput: { nullableFields: nullableOps },
},
fields: (t) => {
const fields: Record<string, InputFieldRef<unknown, 'InputObject'>> = {};
Expand Down

1 comment on commit 8598e34

@vercel
Copy link

@vercel vercel bot commented on 8598e34 Nov 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.