New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

graphql-type-bigint

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-type-bigint

Bigint scalar type for GraphQL.js

1.0.0
latest
Source
npm
Version published
Maintainers
1
Created
Source

GraphQL Bigint

A long integer type for graphql-js. This implementation gives you 53 bits rather than the default 32-bit GraphQLInt.

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. The spec therefore has 32-bit integers to ensure portability to languages that can't represent 64-bit integers. However, if you don't care about that, and you just want to use JavaScript's special 53-bit integers, you can use this scalar type instead!

Usage

$ npm install graphql-type-bigint

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

const Bigint = require('graphql-type-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

graphql

FAQs

Package last updated on 16 May 2018

Did you know?

Socket

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