Registry / development / graphql-tools-types

graphql-tools-types

JSON →
library1.3.2jsnpmunverified

Custom GraphQL scalar types for GraphQL-Tools, providing Void, Integer, Float, String, Date, UUID, and JSON scalars with validation options. Current stable version is 1.3.2. This package is in maintenance mode with infrequent releases. Key differentiators include built-in validation (min/max, regex, UUID format) and struct validation for JSON scalars. Unlike other GraphQL scalar libraries, it integrates directly with graphql-tools' makeExecutableSchema pattern.

npm install graphql-tools-types
INSTALL
IMPORT
SIG · GRAPHQL-TOOLS-TYPE
G
graphql-tools-types
developmentjavascriptv1.3.2
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.

default
import GraphQLToolsTypes from 'graphql-tools-types'
const GraphQLToolsTypes = require('graphql-tools-types')
Package exports a single default export. CommonJS require works but is not recommended for ESM projects.
Void
GraphQLToolsTypes.Void({ name: 'MyVoid' })
import { Void } from 'graphql-tools-types'
Named exports are not available; you must access types via the default import object.
UUID
GraphQLToolsTypes.UUID({ name: 'MyUUID' })
GraphQLToolsTypes.UUID()
Options object is required; name is mandatory for all types.

Quick example showing how to use GraphQLToolsTypes.Date custom scalar with graphql-tools makeExecutableSchema.

import GraphQLToolsTypes from 'graphql-tools-types'; import * as GraphQLTools from 'graphql-tools'; import { graphql } from 'graphql'; const typeDefs = ` scalar MyDate type Query { today: MyDate } `; const resolvers = { MyDate: GraphQLToolsTypes.Date({ name: 'MyDate' }), Query: { today: () => new Date().toISOString() } }; const schema = GraphQLTools.makeExecutableSchema({ typeDefs, resolvers }); graphql(schema, '{ today }').then(result => console.log(result.data));
Debug
Known issues
breakingOptions object is required for all type constructors; calling GraphQLToolsTypes.Void() without arguments will throw an error.
fix
Always pass an options object with at least the 'name' property.
affects: >=1.0.0
deprecatedThe 'regex' option for String type may not work as expected in newer versions of graphql; consider using custom scalars with validate functions instead.
fix
Use a custom scalar with a validate function in graphql-tools instead of relying on regex.
affects: >=1.2.0
gotchaThe UUID type requires the 'pure-uuid' package to be installed as a dependency; if missing, runtime errors occur.
fix
Ensure 'pure-uuid' is listed in your package.json dependencies.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read property 'Void' of undefined
Default import not used correctly, or package not installed.
fix
Use default import: import GraphQLToolsTypes from 'graphql-tools-types';
GraphQLError: Expected type MyDate to be a string
Date scalar expects ISO 8601 string; non-string values are rejected.
fix
Ensure values passed to Date fields are ISO 8601 strings.
Error: Options object with 'name' property is required
Called type constructor without options object.
fix
Pass an options object: { name: 'MyType' }
Upgrade
Version history
1.3.2latest on npm
Audit
Dependencies
pure-uuidrequiredUsed internally for UUID type generation and validation
graphqlrequiredPeer dependency - provides GraphQL type system base classes
Agent activity
50 hits · last 30 days
node
46
Resources
graphql-tools-types — npm install graphql-tools-types · libregistry