Registry / testing / graphql-type-ints

graphql-type-ints

JSON →
library1.0.2jsnpmunverified

GraphQL scalar types for integers with arbitrary precision and bounds, including 8/16/32/64-bit signed and unsigned integers. Version 1.0.2 is the latest stable release. The library uses JavaScript's BigInt for 64-bit integers (GraphQLKind STRING) and supports custom range validation via factory functions. Key differentiator: it provides precise integer types beyond JavaScript's 53-bit number precision, unlike basic GraphQLInt. Requires Node >=10.4.0 and graphql >=0.13.0.

npm install graphql-type-ints
INSTALL
IMPORT
SIG · GRAPHQL-TYPE-INTS
G
graphql-type-ints
testingjavascriptv1.0.2
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.

GraphQLInt8
import { GraphQLInt8 } from 'graphql-type-ints'
const { GraphQLInt8 } = require('graphql-type-ints')
CommonJS require works as well; ESM is preferred for Node >= 10.4
createGraphQLBigIntType
import { createGraphQLBigIntType } from 'graphql-type-ints'
import createGraphQLBigIntType from 'graphql-type-ints'
This is a named export, not default
UINT32_MAX
import { UINT32_MAX } from 'graphql-type-ints'
Named export, also includes other constants like INT32_MIN

Creates a GraphQL schema with GraphQLInt8 and GraphQLBigInt64 scalars, demonstrating usage with graphql-tools.

import { makeExecutableSchema } from 'graphql-tools'; import { GraphQLInt8, GraphQLBigInt64 } from 'graphql-type-ints'; const typeDefs = ` scalar GraphQLInt8 scalar GraphQLBigInt64 type Query { smallInt(v: GraphQLInt8): String bigInt(v: GraphQLBigInt64): String }`; const resolvers = { GraphQLInt8, GraphQLBigInt64, Query: { smallInt: (_, { v }) => `${v}`, bigInt: (_, { v }) => `${v}`, }, }; const schema = makeExecutableSchema({ typeDefs, resolvers }); export default schema;
Debug
Known issues
breakingBigInt64 types serialize as STRING not INT in GraphQL, so your API returns string values for 64-bit integers.
fix
Ensure your client code can handle string-encoded integers for the 64-bit scalar types.
affects: >=1.0.0
deprecatedgraphql-tools is deprecated; use @graphql-tools/schema instead.
fix
Replace import { makeExecutableSchema } from 'graphql-tools' with import { makeExecutableSchema } from '@graphql-tools/schema'.
affects: >=1.0.0
gotchaCustom types with 'name' must be unique; duplicate names cause GraphQL schema error.
fix
Ensure each custom type's name is unique within your schema.
affects: >=1.0.0
gotchaThe 'min' and 'max' parameters for createGraphQLNumberIntType must be within JavaScript safe integer range (Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER).
fix
Use createGraphQLBigIntType or createGraphQLStringIntType for values beyond that range.
affects: >=1.0.0
gotchaBigInt type uses 'bigint' JavaScript type but GraphQL serializes as STRING; parsing input expects bigint or string.
fix
Always convert input to bigint if passing number; use BigInt() or parseInt().
affects: >=1.0.0
Errors
Common errors & fixes
Error: GraphQL scalar type 'GraphQLInt8' must provide a 'serialize' function.
Missing GraphQLInt8 in resolvers map when using graphql-tools.
fix
Include GraphQLInt8 in the resolvers object as shown in quickstart example.
Query failed with error: Expected type GraphQLInt8, found "100" (type String).
Variable provided as string but GraphQL expects integer input.
fix
Ensure input is integer type (not quoted) in GraphQL query: { value(v: 100) }.
TypeError: Cannot mix BigInt and other types, use explicit conversions.
Using BigInt in arithmetic with plain number.
fix
Convert numbers to BigInt: BigInt(5) + someBigInt.
Schema must contain uniquely named types but contains multiple types named "MyInt".
Duplicate custom type name (name argument) provided to createGraphQL*IntType.
fix
Use unique names for each custom type.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
graphqlrequiredpeer dependency required for GraphQLScalarType
Agent activity
6 hits · last 30 days
node
6
Resources
graphql-type-ints — npm install graphql-type-ints · libregistry