Registry / testing / graphql-type

graphql-type

JSON →
library1.1.1jsnpmunverified

graphql-type v1.1.1 is a GraphQL type creation helper that provides functions to quickly define GraphQL scalar types with built-in validation for strings, integers, and floats. It supports bi-directional validation (input and output) as well as uni-directional (input-only or output-only). Key features include min/max length, regex, custom test functions, and custom error messages for strings; min/max and test for integers; plus maxDecimals for floats. Compared to manually creating custom scalars with GraphQL's GraphQLScalarType, graphql-type offers a simpler API and consistent validation patterns. Released under MIT license, the package is stable but has not seen updates since 2018, suggesting low maintenance cadence.

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

createStringType
import { createStringType } from 'graphql-type'
Package is CJS-only; use require() or named import with ESM bundlers. ESM users: the package does not export ESM modules; use dynamic import or bundler config.
createIntType
import { createIntType } from 'graphql-type'
Same import pattern as other create* functions.
createFloatType
import { createFloatType } from 'graphql-type'
Available for float scalars.

Creates a custom GraphQL scalar type for email validation using createStringType.

const { createStringType } = require('graphql-type'); const EmailType = createStringType({ name: 'EmailAddress', min: 5, max: 100, regexp: /^\w+@\w+\.[a-z]{2,}$/i }); console.log(EmailType.name); // EmailAddress
Debug
Known issues
deprecatedPackage has not been updated since 2018. May not work with latest GraphQL versions.
fix
Consider using GraphQL's built-in custom scalars or a more maintained library like graphql-constraint-directive.
affects: >=1.1.1
gotchaThe 'validate' object inside createStringType uses 'min' and 'max' for string length, not for integer boundaries.
fix
For string validation, 'min' and 'max' refer to character length; for int types, they refer to numeric range.
affects: >=1.0.0
gotchaDefault export is not recommended; always use named imports.
fix
Use const { createStringType } = require('graphql-type') instead of const graphqlType = require('graphql-type').
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'graphql-type'
Package not installed or incorrect import path.
fix
Run npm install graphql-type and ensure import path is correct: require('graphql-type') or import from 'graphql-type'.
TypeError: createStringType is not a function
Using default import incorrectly (e.g. import graphqlType from 'graphql-type' for a CJS module).
fix
Use named import: const { createStringType } = require('graphql-type').
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
Resources
graphql-type — npm install graphql-type · libregistry