# graphschematojson

> Convert executable graphql schema to JSON.

Latest version **2.2.2** (published 2019-06-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install graphschematojson
pnpm add graphschematojson
yarn add graphschematojson
bun add graphschematojson
```

Provides the command `graphschematojson`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.2 |
| Published | 2019-06-09 |
| First published | 2018-07-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 20.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Maintainers | jjwtay |

## Links

- npm: https://www.npmjs.com/package/graphschematojson
- Repository: https://github.com/jjwtay/graphSchemaToJson
- Homepage: https://github.com/jjwtay/graphSchemaToJson#readme
- Issues: https://github.com/jjwtay/graphSchemaToJson/issues
- npm.io page: https://npm.io/package/graphschematojson

## Dependencies (4)

- [ramda](https://npm.io/package/ramda.md) ^0.26.1
- [graphql](https://npm.io/package/graphql.md) ^14.3.1
- [typescript](https://npm.io/package/typescript.md) ^3.4.5
- [graphql-tag](https://npm.io/package/graphql-tag.md) ^2.10.1

## Recent versions

- 2.2.2 (latest) — 2019-06-09
- 2.2.1 — 2019-06-02
- 2.1.1 — 2019-06-02
- 2.1.0 — 2019-06-02
- 2.0.0 — 2019-06-01
- 1.2.0 — 2018-07-21
- 1.1.0 — 2018-07-10
- 1.0.2 — 2018-07-08
- 1.0.1 — 2018-07-08
- 1.0.0 — 2018-07-08

## README

# graphSchemaToJson
Convert graphQL Schema to readable Javascript/JSON/Typescript Objects

## Install

    npm i -D graphschematojson

## Example usage CLI

    npx graphschematojson file=./examples/author.graphql outFile=./output.js

## CLI options

| Option | Required | Default | Description |
|--------|----------|---------|-------------|
| file   | No       |         | .graphql or .gql file to use|
| dir    | No       |         | Directory to find graphql files. Specified only if file is not used|
| outFile| Yes      |         | Output file may end in .js  .json  or .ts depending on preference.|

## Example usage Code

    import fs from 'fs'
    import { toSchema } from 'graphschematojson/dist'

    const schema = fs.readFileSync('./test.graphql', 'utf8')

    fs.writeFileSync('./output.json', JSON.stringify(toSchema(schema), null, 4))

## Example output from running npx graphqlschematojson dir=./examples outFile=./output.js

    export default {
        types: {
            Author: {
                fields: {
                    name: {
                        isNullable: false,
                        isList: false,
                        directives: {},
                        type: 'String'
                    },
                    Books: {
                        isNullable: true,
                        isList: true,
                        directives: {
                            Bar: {
                                baz: 'bleh'
                            }
                        },
                        type: 'Book'
                    }
                },
                directives: {
                    Foo: {}
                },
                interfaces: []
            },
            Book: {
                fields: {
                    title: {
                        isNullable: false,
                        isList: false,
                        directives: {},
                        type: 'String'
                    },
                    Authors: {
                        isNullable: false,
                        isList: false,
                        directives: {},
                        type: 'Author'
                    }
                },
                directives: {
                    Bar: {}
                },
                interfaces: []
            }
        },
        unions: {},
        interfaces: {}
    }

---
_Source: https://npm.io/package/graphschematojson · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
