Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQLNullable<Decimal> conversion #3305

Closed
satyaaiosdev opened this issue Dec 20, 2023 · 10 comments
Closed

GraphQLNullable<Decimal> conversion #3305

satyaaiosdev opened this issue Dec 20, 2023 · 10 comments
Assignees
Labels
awaiting response bug Generally incorrect behavior question Issues that have a question which should be addressed

Comments

@satyaaiosdev
Copy link

Question

The conversion of Decimal to GraphQLNullable resulted in odd behavior, such as the addition of extra numbers to the value as shown below.
Take GraphQLNullable, for instance.A portion (0.84) receives 0.83999999999999997
However, after conversion, 0.84 was our need.How can one resolve this kind of problem?

@satyaaiosdev satyaaiosdev added the question Issues that have a question which should be addressed label Dec 20, 2023
@AnthonyMDev
Copy link
Contributor

Can you provide a code sample of what you are doing when this conversion occurs? That is definitely very odd behavior...

@satyaaiosdev
Copy link
Author

let decimal: Decimal = 0.84
let unwrapDecimal = GraphQLNullable.some(0.84)
this is getting 0.83999999999999997 and this value send to backend

@satyaaiosdev
Copy link
Author

satyaaiosdev commented Jan 1, 2024

@AnthonyMDev waiting for your response, FloatingType values are wrongly presiced.

@AnthonyMDev AnthonyMDev added the bug Generally incorrect behavior label Jan 2, 2024
@AnthonyMDev AnthonyMDev added this to the Patch Releases (1.x.x) milestone Jan 2, 2024
@AnthonyMDev
Copy link
Contributor

Hi there. Sorry for the slow response, we've been off for the holidays. Now that we are back, we've got a lot of catch up to do this week. But we'll get someone to look into this further as soon as we can. If you end up finding anything else out in the mean time, please update us here!

@satyaaiosdev
Copy link
Author

Hi @AnthonyMDev , not only GraphQLNullable, while sending Decimal(decimal: 0.83) is converted into 8.0299999999999994

@BobaFetters
Copy link
Member

@satyaaiosdev Can you provide a sample project that demonstrates this issue? In my testing using Decimal and passing it into GraphQLNullable as described doesn't demonstrate the issue so I assume the issue is coming from somewhere this variable is being used or acted upon in some way in your code. A sample project that demonstrates the issue would be helpful for us to determine the cause of the issue.

@satyaaiosdev
Copy link
Author

satyaaiosdev commented Jan 5, 2024

MocupInput(__data: ApolloAPI.InputDict(data: [ "currentBalance": GraphQL.Decimal(decimal:0.83)]))

Than while sending this input request query creating like this
requestBody -----
{
"operationName" : "MocupAggtegate",
"query" : "query MocupAggtegate($input: MocupAggregateInput!) {\n mocupAggregate(input: $input) {\n __typename\n totalValue\n }\n}",
"variables" : {
"input" : {
"totalValue" : 8.0299999999999994,
}
}

@BobaFetters BobaFetters self-assigned this Jan 16, 2024
@BobaFetters
Copy link
Member

BobaFetters commented Jan 16, 2024

@satyaaiosdev sorry for the delayed response ive been out of office dealing with a death in the family.

so you are using GraphQL.Decimal which I assume is a custom scalar you have implemented? Can you share your implementation of that?

@BobaFetters
Copy link
Member

Closing this under the assumption it is no longer an issue. Feel free to reopen with additional info if needed.

Copy link
Contributor

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo iOS usage and allow us to serve you better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response bug Generally incorrect behavior question Issues that have a question which should be addressed
Projects
None yet
Development

No branches or pull requests

3 participants