/graphql-json-to-sdl

A command line utility for converting a JSON GraphQL schema to GraphQL SDL

Primary LanguageTypeScriptMIT LicenseMIT

graphql-json-to-sdl

Version Codecov Downloads/week License

A command line utility for converting a JSON GraphQL schema to GraphQL SDL.

This is useful when you only have a JSON GraphQL schema (e.g. from a code-first GraphQL library that can only produce schemas as .json files) but you need an SDL schema (i.e. .graphql file) for other tooling.

Fields from the JSON schema are sorted before writing the SDL file. This allows for consistent SDL output even when using a GraphQL library that produces JSON schemas with nondeterministic field order.

Usage

$ graphql-json-to-sdl SRC OUT

Arguments:

  • SRC: The JSON GraphQL schema to convert
  • OUT: The output file

Options:

  • -h, --help: show CLI help
  • -v, --version: show CLI version

Example:

$ graphql-json-to-sdl ./schema.json ./schema.graphql

Developing

Install dependencies with:

$ yarn install

To run tests:

$ yarn test

You can also run the CLI in dev mode. For example:

$ ./bin/run --help