gql-bigint contains two scalar types (BigInt
and BigUInt
) for use with gqlgen GraphQL servers.
BigInt
allows GraphQL servers to bypass the 53-bit limit imposed on GraphQL's inbuilt Int
type, and corresponds to the
Go type int64
.
BigUInt
is very similar to BigInt
, except it corresponds to the Go type uint64
, allowing for slightly more headroom
if needed.
Install gql-bigint
using go get -u github.com/xplorfin/gql-bigint
.
Make sure the autobind
entry in your .gqlgen.yml
file has "github.com/xplorfin/gql-bigint"
somewhere in it,
like so:
autobind:
- "github.com/xplorfin/gql-bigint"
[... all your other autobinds ...]
Next, make sure the models
entry in your .gqlgen.yml
is set up to map the scalar types properly when generating:
models:
[... whatever else you have here ...]
BigInt:
model:
- github.com/xplorfin/gql-bigint.BigInt
BigUInt:
model:
- github.com/xplorfin/gql-bigint.BigUInt
Finally, put the following two lines into a .graphql
file where gqlgen will be able to pick it up (I recommand scalars.graphql
):
scalar BigInt
scalar BigUInt
Run go generate ./...
to regenerate your schema/resolvers, and you're done.
Open up an issue or PR, and we'll take a look at it!