Socket
Socket
Sign inDemoInstall

graphql-bigint

Package Overview
Dependencies
1
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    graphql-bigint

A 53-bit wide implementation of integers for GraphQL


Version published
Weekly downloads
6.4K
decreased by-1.16%
Maintainers
1
Install size
9.29 kB
Created
Weekly downloads
 

Readme

Source

graphql-bigint

A wider integer type for graphql-js than the default 32-bit GraphQLInt. This implementation gives you 53-bit integers.

The problem

The GraphQL spec limits its Int type to 32-bits. Maybe you've seen this error before:

GraphQLError: Argument "num" has invalid value 9007199254740990.
              Expected type "Int", found 9007199254740990.

Why? 64-bits would be too large for JavaScript's 53-bit limit. According to Lee Byron, a 52-bit integer spec would have been "too weird" see this issue.

Usage

$ npm install graphql-bigint

Use it the same as any other scalar type, either input or output.

const BigInt = require('graphql-bigint')

const SomeType = new GraphQLObjectType({
  name: 'SomeType',
  fields: {
    numberField: {
      type: BigInt,
      // this would throw an error with the GraphQLInt
      resolve: () => Number.MAX_SAFE_INTEGER 
    }
  }
})

Keywords

FAQs

Last updated on 27 Jul 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc