Gathering detailed insights and metrics for prisma-nestjs-graphql-filter
Gathering detailed insights and metrics for prisma-nestjs-graphql-filter
Gathering detailed insights and metrics for prisma-nestjs-graphql-filter
Gathering detailed insights and metrics for prisma-nestjs-graphql-filter
This package helps you to reduce boilerplate if you want to create Prisma filter input in Graphql
npm install prisma-nestjs-graphql-filter
Typescript
Module System
Node Version
NPM Version
74.1
Supply Chain
99
Quality
75.6
Maintenance
100
Vulnerability
100
License
TypeScript (96.38%)
JavaScript (3.62%)
Total Downloads
2,646
Last Day
2
Last Week
22
Last Month
39
Last Year
1,658
6 Commits
1 Forks
1 Watching
3 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.3.3
Package Id
prisma-nestjs-graphql-filter@1.3.3
Unpacked Size
70.84 kB
Size
10.63 kB
File Count
68
NPM Version
9.5.1
Node Version
18.16.1
Publised On
12 Jul 2023
Cumulative downloads
Total Downloads
Last day
-50%
2
Compared to previous day
Last week
57.1%
22
Compared to previous week
Last month
-77.8%
39
Compared to previous month
Last year
67.8%
1,658
Compared to previous year
This package helps you to reduce boilerplate if you want to create Prisma filter input in Graphql. WhereInput decorator accepts an array of arguments, so you can add all fields with any type as you need.
This package is compatible with all Graphql input types and all classes with InputType decorator. Also you can declare your field input type as array (check the examples below).
Is not necessary add native Input decorator when you use WhereInput or OrderByInput decorators.
You must install class-transformer
package before install if you want to use DecimalFilter
WhereInput and OrderByInput may not work when you nest with each other, due to circular dependency issues. You can use those decorators if you add nested fields with Field decorator inside class.
npm -i prisma-nestjs-graphql-filter
yarn add prisma-nestjs-graphql-filter
1@WhereInput({ type: String, fields: ['hello', 'world'] }) 2class ExampleInput {}
input ExampleInput {
hello: String
world: String
AND: [ExampleInput]
OR: [ExampleInput]
NOT: [ExampleInput]
}
1@WhereInput({ type: ListRelationInput(OtherClass), fields: ['relationField'] }) 2class ExampleInput {}
input ExampleInput {
relationField: OtherClassListRelationWhereInput
AND: [ExampleInput]
OR: [ExampleInput]
NOT: [ExampleInput]
}
input OtherClassListRelationWhereInput {
every: OtherClass
some: OtherClass
none: OtherClass
}
NOTE: This decorator always concat word 'ListRelationWhereInput' to class name and delete words: 'Input' and 'Where' if those are present in original input name.
1@WhereInput( 2 { type: [String], fields: ['hello', 'world'] }, 3 { type: [ListRelationInput(OtherInputClass)], fields: ['relationArray'] } 4) 5class ExampleInputArray {}
input ExampleInputArray {
hello: [String]
world: [String]
relationField: [StringListRelationWhereInput]
}
1@OrderByInput({ type: SortOrder, fields: ['hello', 'world'] }) 2class ExampleInput {}
input ExampleInput {
hello: SortOrder //asc | desc
world: SortOrder //asc | desc
}
1@OrderByInput({ type: SortOrder, fields: ['hello'] }) 2class NestedOrderBy {} 3 4@OrderByInput({ type: NestedOrderBy, fields: ['nestedField'] }) 5class ExampleInput {}
input ExampleInput {
nestedField: NestedOrderBy
}
input NestedOrderBy {
hello: SortOrder
}
Because all fields injected with WhereInput or OrderByInput are not declared by the decorator explicitly, Typescript can't recognizes the class fields. To avoid this and helps IDE to hinting, you can extend CastToAbstract
with prisma where type.
For example:
1class ExampleInputArray extends CastToAbstract<Prisma.HelloWorldWhereInput>() {}
There are many prisma filter types and extra types availables that you can use as:
No vulnerabilities found.
No security vulnerabilities found.