json2gql

0.0.6 • Public • Published

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
  }
}

Readme

Keywords

Package Sidebar

Install

npm i json2gql

Weekly Downloads

0

Version

0.0.6

License

ISC

Unpacked Size

6.38 kB

Total Files

9

Last publish

Collaborators

  • tommy.york