graphql-type-decimal
v1.0.0
Published
Decimal scalar type for GraphQL.js
Downloads
954
Readme
graphql-type-decimal
Decimal scalar type for GraphQL.js primarily for currencies.
Ex: 21.01
Usage
This package exports a Decimal scalar GraphQL.js type:
import GraphQLDecimal from 'graphql-type-decimal';
SDL with GraphQL-tools
When using the SDL with GraphQL-tools, define GraphQLDecimal
as the resolver for the appropriate scalar type in your schema:
import { makeExecutableSchema } from 'graphql-tools';
import GraphQLDecimal from 'graphql-type-decimal';
const typeDefs = `
scalar Decimal
type MyType {
myField: Decimal
}
# ...
`;
const resolvers = {
Decimal: GraphQLDecimal,
};
export default makeExecutableSchema({ typeDefs, resolvers });
Dependency
This library uses bignumber.js
Related
This repository is inspired by graphql-type-datetime