Converts GraphQL Schema Definition Language (SDL) to JSON Schema (draft-04). Version 1.0.0. Supports scalars (including custom), enums, unions, object types with required fields, lists, and recursive references. Output is compatible with react-jsonschema-form. No active releases since initial 2016. Differentiators: simple string-to-object conversion without GraphQL execution, ESM-only via npm package. Caveats: no support for interfaces, input types, directives, or deprecation. Output uses non-standard types like GRAPHQL_SCALAR for custom scalars and GRAPHQL_UNION.
npm install graphql-to-json-schemaNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates converting a simple GraphQL SDL string to a JSON Schema object.
Use dynamic import() or convert project to ESM.
Post-process output to replace GRAPHQL_SCALAR with 'string' or skip custom scalars.
Pre-process SDL to remove unsupported elements or use another library like graphql-2-json-schema.
Check if GraphQL schema marks fields correctly; nullable fields may appear as required if not handled.
Use `import transform from 'graphql-to-json-schema'` (no curly braces).
Switch to ES modules or use dynamic import: `const transform = (await import('graphql-to-json-schema')).default;`Run `npm install graphql` as a direct dependency.