# json2gql

> Generate a GraphQL query from a JSON object.

Latest version **0.0.6** (published 2019-11-25) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2019-11-25 |
| First published | 2019-05-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Tommy York |
| Maintainers | tommy.york |
| Keywords | GraphQL |

## Links

- npm: https://www.npmjs.com/package/json2gql
- Repository: https://github.com/tommyyork/generateGQLQueryFromObject
- Homepage: https://github.com/tommyyork/json2gql#readme
- Issues: https://github.com/tommyyork/json2gql/issues
- npm.io page: https://npm.io/package/json2gql

## Dependencies (2)

- [deepmerge](https://npm.io/package/deepmerge.md) ^3.0.0
- [prettyjson](https://npm.io/package/prettyjson.md) ^1.2.1

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 0.0.6 (latest) — 2019-11-25
- 0.0.5 — 2019-11-25
- 0.0.4 — 2019-05-29
- 0.0.2 — 2019-05-29

## README

<img src="https://travis-ci.com/tommyyork/json2gql.svg?branch=master"/>

Converts a given JSON object, containing GraphQL data, to a GraphQL-style query, containing only the keys required to request the data in the JSON object. Useful for large arrays, with objects inside that could contain a variety of different keys and objects.

For example, converts this:

```
json2gql({
  "shortName": "product shortname",
  "productFeatures": {
    "content": [
      {
        "key": "welcomeBonus",
        "header": "Welcome Bonus",
        "desc": [
          {
            "type": "text",
            "text": "-"
          }
        ]
      },
      {
        "key": "annualFee",
        "header": "Annual Fee",
        "style": "example style"
      }
    ]
  }
})
```

Returns this:

```
shortName
productFeatures {
  content {
    key
    header
    desc {
      type
      text
    }
    style
  }
}
```

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