1.1.12 • Published 4 years ago

graphql-converter v1.1.12

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

This is a package to help you in creating your graphql query out of array of string

Instruction

Installation

npm i graphql-converter

Simple use

import { gqlBuilder } from "graphql-converter";
// or
const gqlBuilder = require("graphql-converter").gqlBuilder;

// then you can convert your query
gqlBuilder(["test"]) // output is: { test }


gqlBuilder(["user.firstname","user.family","user.role", "user.email","user.address.street","user.address.postalCode"]) 
/* output is:
{
    user{
        firstname
        family
        role
        email
        address {
            street
            postalCode
        }
    }
}
/*

Use with qgl with variable

import gql from 'graphql-tag';
import { gqlBuilder } from "graphql-converter";


export const LOAD_LANG = gql`
query languages($token: String!){
languages(input:{perPage:100,page:1,q:"*",token:$token})
${gqlBuilder([
  "count",
  "result.key",
  "result.title",
  "result.id"
])}
}`
/* 
equal with:
export const LOAD_LANG = gql`
query languages($token: String!){
languages(input:{perPage:100,page:1,q:"*",token:$token}){
    count
    result{
        key
        title
        id
        }
    }
}`
*/
1.1.51

4 years ago

1.1.12

4 years ago

1.1.11

4 years ago

1.1.5

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago