gql_bigint

package module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2021 License: MIT Imports: 3 Imported by: 3

README

gql-bigint

Go Reference Renovate enabled Tests Linter

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.

Usage

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.

Contributing

Open up an issue or PR, and we'll take a look at it!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BigInt

type BigInt int64

BigInt represents a 64-bit signed integer (int64) which is usable as a GraphQL scalar type.

func (BigInt) Float64 added in v0.4.0

func (b BigInt) Float64() float64

Float64 returns the float64 representation of b

func (BigInt) Int64

func (b BigInt) Int64() int64

Int64 returns the underlying inbuilt int64 value of b.

func (BigInt) MarshalGQL

func (b BigInt) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface found in gqlgen, allowing the type to be marshaled by gqlgen and sent over the wire.

func (BigInt) Ptr

func (b BigInt) Ptr() *BigInt

Ptr returns a pointer to b.

func (*BigInt) UnmarshalGQL

func (b *BigInt) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface found in gqlgen, allowing the type to be received by a graphql client and unmarshaled.

type BigUInt

type BigUInt uint64

BigUInt represents a 64-bit unsigned integer (uint64) which is usable as a GraphQL scalar type.

func (BigUInt) Float64 added in v0.4.0

func (b BigUInt) Float64() float64

Float64 returns the float64 representation of b

func (BigUInt) MarshalGQL

func (b BigUInt) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface found in gqlgen, allowing the type to be marshaled by gqlgen and sent over the wire.

func (BigUInt) Ptr

func (b BigUInt) Ptr() *BigUInt

Ptr returns a pointer to b.

func (BigUInt) UInt64

func (b BigUInt) UInt64() uint64

UInt64 returns the underlying inbuilt uint64 value of b.

func (*BigUInt) UnmarshalGQL

func (b *BigUInt) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface found in gqlgen, allowing the type to be received by a graphql client and unmarshaled.

Directories

Path Synopsis
gql-test module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL