https://github.com/unlight/prisma-graphql-type-decimal
GraphQL type for Prisma's Decimal scalar, wrapper around decimal.js
https://github.com/unlight/prisma-graphql-type-decimal
decimal-js graphql graphql-scalar graphql-scalars graphql-type-scalar graphql-types prisma-client
Last synced: about 1 month ago
JSON representation
GraphQL type for Prisma's Decimal scalar, wrapper around decimal.js
- Host: GitHub
- URL: https://github.com/unlight/prisma-graphql-type-decimal
- Owner: unlight
- Created: 2021-04-20T13:12:02.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2026-01-31T10:30:09.000Z (4 months ago)
- Last Synced: 2026-01-31T12:38:21.697Z (4 months ago)
- Topics: decimal-js, graphql, graphql-scalar, graphql-scalars, graphql-type-scalar, graphql-types, prisma-client
- Language: TypeScript
- Homepage:
- Size: 1010 KB
- Stars: 18
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# prisma-graphql-type-decimal
GraphQL type for Prisma's Decimal scalar, wrapper around [decimal.js](https://github.com/MikeMcl/decimal.js/)
Created because `@prisma/client` has bundled `decimal.js`
## Install
```sh
npm install prisma-graphql-type-decimal
```
## Usage
Example usage with NestJS GraphQL code first approach:
```ts
import { Decimal } from '@prisma/client-runtime-utils';
import { transformToDecimal } from 'prisma-graphql-type-decimal';
import { Type, Transform } from 'class-transformer';
@ObjectType()
export class User {
/**
* Trick to avoid error when using `@Field(() => GraphQLDecimal)`
*/
@Field(() => GraphQLDecimal)
@Type(() => Object)
@Transform(transformToDecimal)
money: Decimal;
@Type(() => Object)
@Transform(transformToDecimal)
moneys!: Array;
}
// In nested object
class Transfers {
@Type(() => Object)
@Transform(transformToDecimal)
moneys!: Array;
}
class Container {
@Type(() => Transfers)
set!: Transfers;
}
```
## License
[MIT License](https://opensource.org/licenses/MIT) (c) 2026