Skip to content

smaro-nitr/axios-graphql-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

axios-graphql-builder

About

A light weight library to generate Axios`s GraphQL query from JSON.


 

Installation

Local installation

npm install axios-graphql-builder --save


 

Functionality Available

Syntax Parameter * Output
buildQuery JSON Object*, Param (Optional) GraphQL Query for Axios

*Note: Last child in JSON object hierarchy should be assigned null value


 

Usage

Once installed in your project. It can be used as:

Example:

import { buildQuery } from 'axios-graphql-builder'

const jsonInput = {
  query: {
    a: null,
    b: null,
    c: {
      c1: null,
      c2: null
    }
  }
}

const paramList = [{ key: 'a', param: 'id: 10' }]

const output = buildQuery(jsonInput, paramList)

console.log(output) >>> { "query": "query \n a(id: 10) \n b \n c { \n c1 \n c2 \n } \n " }


 

Output

  • buildQuery: Return a GraphQl Query which can be directly passed into Axios.


 

Contact

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published