Skip to content

Anyone using Prisma Plugin exposing decimal types? #451

Answered by hayes
marceloverdijk asked this question in Q&A
Discussion options

You must be logged in to vote

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 number but you could include the decimal.js type there, and then typescript would likely allow that. I don't know i…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@marceloverdijk
Comment options

@GeKVe
Comment options

@hayes
Comment options

@GeKVe
Comment options

Answer selected by hayes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants