Anyone using Prisma Plugin exposing decimal types? #451
-
Prisma uses decimal.js for Pisma Using e.g. I'm already using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I haven't used this myself. The place to start would probably to define it as: t.field({
type: ['Float'], // if its a list, or just `'Float'` if its not a list
resolve: (parent) => parent.points
}) This will give you a better message on why typescript thinks this is not safe. I haven't used decimal.js myself, so not sure about how it works. There are a few pieces at play. When you create the builder, you can define types for the scalars in your schema (you probably already have this set up for other scalars) This also works for built in scalars like float. It defaults to Hope this helps a little, I know it's not a very complete answer |
Beta Was this translation helpful? Give feedback.
I haven't used this myself. The place to start would probably to define it as:
This will give you a better message on why typescript thinks this is not safe. I haven't used decimal.js myself, so not sure about how it works. There are a few pieces at play. When you create the builder, you can define types for the scalars in your schema (you probably already have this set up for other scalars) This also works for built in scalars like float. It defaults to
number
but you could include the decimal.js type there, and then typescript would likely allow that. I don't know i…