Registry / storage / graphql-type-long

graphql-type-long

JSON →
library0.1.1jsnpmunverified

A GraphQL scalar type that extends 52-bit signed integer support for GraphQL.js. Current version 0.1.1, low release cadence. Enables serialization and parsing of integers beyond JavaScript's safe integer range (up to 52 bits). Compared to other GraphQL integer types (e.g., BigInt), this provides a lightweight solution for 52-bit integers without external dependencies. Peer dependency on GraphQL 0.9-0.13. Not actively maintained, but functional for legacy projects.

npm install graphql-type-long
INSTALL
IMPORT
SIG · GRAPHQL-TYPE-LONG
G
graphql-type-long
storagejavascriptv0.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GraphQLLong
import GraphQLLong from 'graphql-type-long'
const GraphQLLong = require('graphql-type-long').default
Default export in ESM; CommonJS require may need '.default' depending on bundler settings.
GraphQLLong
const GraphQLLong = require('graphql-type-long').default
const GraphQLLong = require('graphql-type-long')
In CommonJS, require returns the module exports object, so accessing .default is needed for the type.
GraphQLLong
import { GraphQLLong } from 'graphql-type-long'
import { GraphQLLong as Long } from 'graphql-type-long'
Named import also works if the environment supports package.json exports; but default import is more reliable.

Shows how to define a GraphQL schema using the GraphQLLong scalar type with a query and a mutation argument.

import { GraphQLObjectType, GraphQLSchema, GraphQLString } from 'graphql'; import GraphQLLong from 'graphql-type-long'; const schema = new GraphQLSchema({ query: new GraphQLObjectType({ name: 'Query', fields: { largeNumber: { type: GraphQLLong, resolve: () => 9007199254740991, }, echo: { type: GraphQLLong, args: { input: { type: GraphQLLong } }, resolve: (_, { input }) => input, }, }, }), }); // Query: { echo(input: 9007199254740991) }
Debug
Known issues
deprecatedPackage uses older peer dependency graphql@^0.9.1 || ^0.10.0 || ^0.12.0 || ^0.13.0. Not updated for GraphQL v15 or v16. May have compatibility issues with newer GraphQL versions.
fix
Use a more modern package like graphql-bigint or implement custom scalar type for GraphQL v15+.
affects: >=0.1.0
breakingIf using CommonJS require, you must access the .default property. Direct require returns an object with default property.
fix
Use const GraphQLLong = require('graphql-type-long').default
affects: >=0.1.0
gotchaGraphQLLong only supports integers within the safe 52-bit range (-4503599627370496 to 4503599627370495). Values outside this range may cause precision loss or errors.
fix
Ensure all input/output values are within the 52-bit signed integer range. For larger values, use BigInt or a custom scalar.
affects: >=0.1.0
gotchaGraphQL-Long serializes integers as numbers. JavaScript numbers are 64-bit floats with 53-bit integer precision; be cautious of rounding for values near the upper bound.
fix
For precise handling of 52-bit integers, consider using strings if JSON transport is required.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'prototype')
Using require('graphql-type-long') without .default in CommonJS environment.
fix
Use const GraphQLLong = require('graphql-type-long').default
Error: GraphQLLong must be an instance of GraphQLScalarType
Improper import where GraphQLLong is not correctly instantiated as a GraphQL scalar.
fix
Ensure you import GraphQLLong correctly: import GraphQLLong from 'graphql-type-long'
Unknown type "Long". Did you mean "Float" or "Int"?
Attempting to use GraphQLLong without adding it to the schema types.
fix
Add GraphQLLong to your schema configuration as shown in the quickstart code.
Expected value of type "Long" but received: 1e+21
Input value exceeds the 52-bit integer range or is represented in scientific notation.
fix
Ensure input is a 52-bit integer within range, provided as a plain number without scientific notation.
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies
graphqloptionalpeer dependency; required to define and use custom scalar types
Agent activity
23 hits · last 30 days
node
22
Resources
graphql-type-long — npm install graphql-type-long · libregistry