Cauen / prisma-generator-pothos-codegen

The fastest way to create a fully customizable CRUD Graphql API from Prisma Schema.
https://www.npmjs.com/package/prisma-generator-pothos-codegen
95 stars 16 forks source link

Add missing cast of type object for decimal scalar #41

Closed c7h closed 1 year ago

c7h commented 1 year ago

I'm running into this weird problem where my DecimalScalar return with type object. This PR fixes this Issues.

Cauen commented 1 year ago

Hello @c7h

I couldn't understand your use case In the code, we reject all inputs other than string and number In which case are you going to correctly convert an object to a float before inserting it into a "decimal" column?

c7h commented 1 year ago

In the code, we reject all inputs other than string and number

this is exactly the problem I'm trying to solve. For some reason, I'm receiving this.

Debugger view with updated code snippet

I am not sure why I am receiving an object instead of an int, float or string.

A similar problems happens with DateTime Objects, which are also of type object:

image

Cauen commented 1 year ago

You're correct.

typeof new Number(7.78) === "object"

I'll expand your code to date and accept. Thanks for contributing :D

c7h commented 1 year ago

Hi @Cauen! any updates on this one? :-)

Cauen commented 1 year ago

Merged, thanks @c7h \o/

c7h commented 1 year ago

many thanks! works like a charm! ⭐