axios-graphql-builder
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

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

Package Sidebar

Install

npm i axios-graphql-builder

Weekly Downloads

30

Version

1.1.1

License

MIT

Unpacked Size

5.84 kB

Total Files

9

Last publish

Collaborators

  • smaro.nitr