Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joonhocho/graphql-scalar
Configurable custom GraphQL Scalars (string, number, date, etc) with sanitization / validation / transformation in TypeScript.
https://github.com/joonhocho/graphql-scalar
Last synced: 4 days ago
JSON representation
Configurable custom GraphQL Scalars (string, number, date, etc) with sanitization / validation / transformation in TypeScript.
- Host: GitHub
- URL: https://github.com/joonhocho/graphql-scalar
- Owner: joonhocho
- License: mit
- Created: 2019-06-28T04:20:15.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-11T01:01:53.000Z (over 1 year ago)
- Last Synced: 2024-09-19T17:35:27.361Z (about 2 months ago)
- Language: TypeScript
- Homepage:
- Size: 1.01 MB
- Stars: 23
- Watchers: 3
- Forks: 2
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ccamel - joonhocho/graphql-scalar - Configurable custom GraphQL Scalars (string, number, date, etc) with sanitization / validation / transformation in TypeScript. (TypeScript)
README
# graphql-scalar
Configurable custom GraphQL Scalars (string, number, date, etc) with sanitization / validation / transformation in TypeScript.[![npm version](https://badge.fury.io/js/graphql-scalar.svg)](https://badge.fury.io/js/graphql-scalar)
[![Build Status](https://travis-ci.org/joonhocho/graphql-scalar.svg?branch=master)](https://travis-ci.org/joonhocho/graphql-scalar)
[![Coverage Status](https://coveralls.io/repos/github/joonhocho/graphql-scalar/badge.svg?branch=master)](https://coveralls.io/github/joonhocho/graphql-scalar?branch=master)
[![Dependency Status](https://david-dm.org/joonhocho/graphql-scalar.svg)](https://david-dm.org/joonhocho/graphql-scalar)
![npm type definitions](https://img.shields.io/npm/types/graphql-scalar.svg)
[![GitHub](https://img.shields.io/github/license/joonhocho/graphql-scalar.svg)](https://github.com/joonhocho/graphql-scalar/blob/master/LICENSE)TypeScript version (with breaking changes) of the following repos:
[joonhocho/graphql-input-number](https://github.com/joonhocho/graphql-input-number)
[joonhocho/graphql-input-string](https://github.com/joonhocho/graphql-input-string)## Get Started
```
npm install graphql-scalar
```
or
```
yarn add graphql-scalar
```## How to Use
```typescript
import { createStringScalar, createIntScalar, createFloatScalar } from 'graphql-scalar';const stringScalar = createStringScalar({
name: string;
description?: string;
capitalize?: 'characters' | 'words' | 'sentences' | 'first';
collapseWhitespace?: boolean;
lowercase?: boolean;
maxLength?: number;
minLength?: number;
nonEmpty?: boolean;
pattern?: RegExp | string;
singleline?: string;
trim?: boolean;
trimLeft?: boolean;
trimRight?: boolean;
truncate?: number;
uppercase?: boolean;
coerce?: ScalarCoerceFunction;
errorHandler?: ScalarParseErrorHandler;
parse?: ScalarParseFunction;
sanitize?: ScalarSanitizeFunction;
serialize?: ScalarSerializeFunction;
validate?: ScalarValidateFunction;
})const intScalar = createIntScalar({
name: string;
description?: string;
maximum?: number;
minimum?: number;
coerce?: ScalarCoerceFunction;
errorHandler?: ScalarParseErrorHandler;
parse?: ScalarParseFunction;
sanitize?: ScalarSanitizeFunction;
serialize?: ScalarSerializeFunction;
validate?: ScalarValidateFunction;
})
```## License
[MIT License](https://github.com/joonhocho/graphql-scalar/blob/master/LICENSE)