Registry / devops / graphql-json-schema

graphql-json-schema

JSON →
library0.1.2jsnpmunverified

Converts GraphQL Schema Language (SDL) to JSON Schema (draft-04). Stable version 0.1.2, low release cadence. Differentiates by enabling reuse of GraphQL type definitions in JSON Schema contexts; outputs definitions with GraphQL-specific constructs (e.g., GRAPHQL_SCALAR, GRAPHQL_UNION) rather than fully standard JSON Schema, which may require post-processing.

npm install graphql-json-schema
INSTALL
IMPORT
SIG · GRAPHQL-JSON-SCHEM
G
graphql-json-schema
devopsjavascriptv0.1.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.

transform (default)
import transform from 'graphql-json-schema';
const { transform } = require('graphql-json-schema');
Package exports a single default function; named import will be undefined.
transform (CommonJS)
const transform = require('graphql-json-schema');
const { default: transform } = require('graphql-json-schema');
default export is not wrapped in an object.
TypeScript types
import transform from 'graphql-json-schema';
No type definitions shipped; use @types/graphql-json-schema or declare module.

Shows basic usage: convert GraphQL SDL string to JSON Schema object and print it.

import transform from 'graphql-json-schema'; const schema = transform(` type Query { hello: String! } `); console.log(JSON.stringify(schema, null, 2));
Debug
Known issues
gotchaOutput JSON Schema uses custom types like GRAPHQL_SCALAR, GRAPHQL_UNION, GRAPHQL_ENUM which are not standard JSON Schema types and may not validate with standard validators.
fix
Post-process the output to replace custom types with standard ones, or use a tool that understands these extensions.
affects: <=0.1.2
gotchaThe output schema uses JSON Schema draft-04 ($schema: http://json-schema.org/draft-04/schema#), which is outdated and may not be compatible with newer validators.
fix
Use a validator that supports draft-04, or convert the output to a later draft.
affects: <=0.1.2
gotchaGraphQL scalars are transformed to JSON Schema type 'integer' for Int, 'number' for Float, etc. but custom scalars become GRAPHQL_SCALAR with no type mapping.
fix
Define explicit mapping for custom scalars if needed after conversion.
affects: <=0.1.2
deprecatedPackage is rarely updated; last release 0.1.2 (unclear date). Future compatibility with newer GraphQL spec or JSON Schema drafts is uncertain.
fix
Consider alternative libraries like graphql-2-json-schema or graphql-schema-to-json-schema.
affects: <=0.1.2
Errors
Common errors & fixes
Cannot find module 'graphql-json-schema'
Package not installed or import path incorrect.
fix
Run 'npm install graphql-json-schema' and ensure import statement matches CommonJS or ESM pattern.
TypeError: transform is not a function
Used named import { transform } instead of default import.
fix
Use default import: import transform from 'graphql-json-schema' or const transform = require('graphql-json-schema').
Schema is not valid: data["$schema"] must be equal to one of the allowed values
Output uses draft-04 $schema, but validator expects later draft.
fix
Use a valid JSON Schema draft-04 validator, or remove the $schema property from output.
Upgrade
Version history
0.1.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
graphql-json-schema — npm install graphql-json-schema · libregistry