Skip to content

Nberezhnoy/apollo-type-bigint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 });

About

53-bit and 63-bit integer implementation for GraphQL

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages