Skip to content

Simple utility that takes a javascript object and turns it into a GraphQL query.

Notifications You must be signed in to change notification settings

sf0rman/json2Gql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

json2Gql

This is a simple, zero dependency, utility that takes a javascript object and turns it into a GraphQL query.

Installation

npm i json-2-graphql-query

Usage

const query = json2Gql(queryObj: object)

Example

const query = json2Gql({
  prop1: "1",
  arr: [
    { arrProp1: 1, arrProp2: "2" },
    { arrProp1: 2, arrProp2: "2", extraProp: true },
    { arrProp1: 3, arrProp2: "2" }
  ],
  prop2: true
})

console.log(query):

// OUTPUT
"{ prop1 arr { arrProp1 arrProp2 extraProp } prop2 }"

About

Simple utility that takes a javascript object and turns it into a GraphQL query.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published