Registry / testing / graphql-json-schema-fix

graphql-json-schema-fix

JSON →
library1.0.0jsnpmunverified

Converts GraphQL Schema Language to JSON Schema. Version 1.0.0, maintenance mode. A fork of the original graphql-json-schema with fixes for modern SDL syntax, including support for union types, scalar definitions, and required fields. Unlike other converters, this library outputs draft-04 JSON Schema with custom annotations like GRAPHQL_SCALAR and GRAPHQL_ENUM. Release cadence is low; last release was May 2020. Differentiator: handles GraphQL-specific types and includes field arguments.

npm install graphql-json-schema-fix
INSTALL
IMPORT
SIG · GRAPHQL-JSON-SCHEM
G
graphql-json-schema-fix
testingjavascriptv1.0.0
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
import transform from '@yoshokatana/graphql-json-schema';
const { transform } = require('graphql-json-schema-fix');
This package is ESM-only and exports a default function; CommonJS require with named destructuring will fail.
transform
const transform = require('@yoshokatana/graphql-json-schema');
If using CommonJS, require the default export as shown.
default
import transform from '@yoshokatana/graphql-json-schema';
import { default as transform } from '@yoshokatana/graphql-json-schema';
The library's main function is exported as default; do not destructure.

Demonstrates converting a basic GraphQL schema with scalar and type definitions to JSON Schema using the default import.

import transform from '@yoshokatana/graphql-json-schema'; const schema = transform(` scalar DateTime type Query { user(id: ID!): User } type User { id: ID! name: String createdAt: DateTime } `); console.log(JSON.stringify(schema, null, 2)); // Output includes $schema, definitions, and object properties
Debug
Known issues
deprecatedThe package is a fork with limited maintenance; prefer graphql-json-schema (original) or graphql-to-json-schema for active development.
fix
Use graphql-to-json-schema or the original graphql-json-schema if you need ongoing support.
affects: <1.1
gotchaOutput uses JSON Schema draft-04; modern tools expect draft-07 or later. You may need to convert the output.
fix
Use a tool like jsonschema-draft4-to-draft7 to upgrade the schema.
affects: >=0.0
gotchaCustom GraphQL types (scalar, enum, union) are represented with type GRAPHQL_SCALAR, GRAPHQL_ENUM, GRAPHQL_UNION which are not standard JSON Schema.
fix
Post-process the output to replace these with JSON Schema-compliant types.
affects: >=0.0
gotchaField arguments are included in the output as an 'arguments' array, but JSON Schema does not support this. This may cause validation errors.
fix
Strip 'arguments' properties from the output or use a different library that does not include them.
affects: >=0.0
Errors
Common errors & fixes
Cannot find module 'graphql-json-schema'
Package is installed under @yoshokatana/graphql-json-schema, not graphql-json-schema.
fix
Install with 'npm install @yoshokatana/graphql-json-schema' and import accordingly.
TypeError: transform is not a function
Using named import or destructuring require instead of default import.
fix
Use 'import transform from ...' or 'const transform = require(...)'.
SyntaxError: Unexpected token 'scalar'
The input contains SDL that this version does not support (e.g., directive definitions).
fix
Remove unsupported SDL elements or use a more up-to-date library.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

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