Open Szer opened 9 months ago
Hi @Szer,
Can you provide an example of invalid data you have been able to store ? the db data is supposed to be a decimal and should still be stored at the configured precision and then be usable correctly.
Considering decimals are not a native js type we will always handle numbers and the end user will have to either use a dedicated math lib or receive the data in another language to make a difference 🤔
Bug report
Create a field with "type": "decimal" in Strapi. It is represented as a
Float
Scalar in the GQL Schema. https://github.com/strapi/strapi/blob/6a58621932ad3d83bf9d6928c1871e7906adcd59/packages/plugins/graphql/server/src/services/constants.ts#L54Required System information
Describe the bug
Decimals can't represented as numbers with floating point as they have arbitrary level of precision and prone to rounding errors. Strapi documentation states that Strapi supports both
Floats
andDecimals
whereDecimals
should be used to avoid rounding errors.Mapping
decimal
tofloat
in GQL type system breaks that assumption as now all clients will usesingle
ordouble
floating numbers when talking to Strapi with such schemaSteps to reproduce the behavior
Create a field with "type": "decimal" in Strapi. It is represented as a
Float
Scalar in the GQL Schema.Expected behavior
It should be its own custom scalar called
Decimal
(like JSON, Date or DateTime Strapi already uses for other types`Screenshots
N/A
Code snippets
N/A
Additional context
It is not possible in general to intervene on the Nexus level and retype the OutputField because information that field had "decimal" type in Strapi already lost on Nexus level.