Skip to content

acomagu/graphql-to-json-schema

Repository files navigation

GraphQL Schema to JSON Schema converter

Playground

Installation

npm i @acomagu/graphql-to-json-schema

Usage

import * as graphql from 'graphql';
import { jsonSchemaFromGraphQlType } from '@acomagu/graphql-to-json-schema';

// Get type object to be converted to JSON Schema.
const graphqlSchema = graphql.buildSchema('...');
const type = graphqlSchema.getType('Query');
if (!graphql.isObjectType(type)) throw new Error('The type is not object type.');

// Convert it.
const jsonSchema = jsonSchemaFromGraphQlType(type);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published