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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.6
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.6
    0
  • 0.0.5
    0
  • 0.0.4
    0
  • 0.0.2
    0

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