apollo-type-bigint
v0.1.3
Published
53-bit and 63-bit integer implementation for GraphQL
Downloads
12,678
Maintainers
Readme
apollo-type-bigint
BigInt integer type for Apollo server. This package provides 2 implementation options for working with large integers.
First implementation
This implementation allows working with only 53 bit integers. To work in the 53-bit number mode, you need to create an instance of the GraphQLBigInt class and pass the string "safe" to the constructor.
Example
import { makeExecutableSchema } from "graphql-tools";
import BigInt from "apollo-type-bigint";
const typeDefs = `
scalar BigInt
type Query {
Test: BigInt
}
`;
const resolvers = {
BigInt: new BigInt("safe")
};
export default makeExecutableSchema({ typeDefs, resolvers });
Second implementation
The second implementation allows you to work with 63 bit integers using a new data type in JavaScript - BigInt. To work in this mode, you need to create an instance of the GraphQLBigInt class and pass the "bigInt" to the constructor for the term.
Example
import { makeExecutableSchema } from "graphql-tools";
import BigInt from "apollo-type-bigint";
const typeDefs = `
scalar BigInt
type Query {
Test: BigInt
}
`;
const resolvers = {
BigInt: new BigInt("bigInt")
};
export default makeExecutableSchema({ typeDefs, resolvers });