Fluent Commerce Logo
Docs
Sign In

Convert a JSON Introspection result to Schema Definition Language (SDL)

How-to Guide

Author:

Fluent Commerce

Changed on:

9 Apr 2024

Key Points

  • Converting JSON Introspection to SDL allows for a human-readable format of GraphQL schema, which is essential for documentation and understanding the API structure.
  • Tools such as GraphQL Voyager and Apollo Studio can automate the conversion process, providing a visual representation and SDL output without manual coding.
  • Understanding the structure of the introspection query result is crucial for manually converting the JSON to SDL, should automated tools not be available or suitable.

Steps

Step arrow right iconPrerequisites

  • NodeJS
  • Response file of a JSON Introspection Query.

Step arrow right iconSteps to Follow

  • Open a terminal / command prompt, and run the following command to install the Node package 
    `graphql-introspection-json-to-sdl`
    `npm install -g graphql-introspection-json-to-sdl`
  • Once installed, run the following command to convert a JSON file to GraphQL SDL file.
    `graphql-introspection-json-to-sdl <path-to-instrospection-query-result-json-file> > <path-to-result-sdl-file>`
    Example (from the same direction as the JSON schema file): 
    `graphql-introspection-json-to-sdl fluent-graphql.json > fluent-graphql.graphql`
Fluent Commerce

Fluent Commerce