99designs / 99designs/gqlgen

Enable fix float point 2 decimal place

Open
#3,018 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
10.8k
Forks
1.3k
Avg merge
2d 36m
Merged PRs (30d)
26

Description

### What happened?
If the type is of type `Float` or `Decimal` (custom from https://github.com/shopspring/decimal) and the value have trailing zero, it will not show the trailing zero.
Eg 191.80 is showing as 191.8

### What did you expect?
191.80 Supposed to show 191.80

### Minimal graphql.schema and models to reproduce
even when implementing MarshalGQL (for decimal) doesnt work.

func (y Decimal) MarshalGQL(w io.Writer) {
fmt.Fprintf(w, decimal.Decimal(y).StringFixed(2))
}

### versions
- `go run github.com/99designs/gqlgen version`?
v0.17.45
- `go version`?
1.21.5

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.