0.1.0 • Published 4 years ago
gql-query-generator v0.1.0
gql-query-generator
This package is a class that allows you to compose a GraphQL
query from a set of arrays and objects of any nested filter or query body.
Build
Clone this repository
git clone git@github.com:dastanaron/gql-query-generator.git
Go to folder
cd js-graphql-query-builder
and run command
yarn install
yarn run build
You can also npm
for build and install ependencies
Install
You can install old version with npm
npm install js-graphql-query-lib
Params
let Query = new QueryBuilder('Alias', filter, select);
Alias - Database index; filter - filter (must be Object) select - query body (must be an array with nested objects)
Example
const QueryBuilder = require('./dist/GraphQLBuilder.js').default;
let filter = {
lang: 'en',
id: 755,
DateOfBirth: ["2018-04-23 00:00:00", "2018-04-23 23:59:59"],
favorites: true,
};
let select = [
'id',
{
account: ['bill', 'transaction', 'country']
},
'name',
{
passport: [
{placeofissue: ['country', 'city']},
'seria', 'number'
]
}
,
];
let QueryObject = new QueryBuilder('User', filter, select);
console.log(QueryObject.getQuery());
output:
{User(lang: "en", id: 755, DateOfBirth: ["2018-04-23 00:00:00", "2018-04-23 23:59:59"], favorites: true){id account{bill transaction country } name passport{placeofissue{country city } seria number } }}
See example.js
node example.js
example to RunKit
0.1.0
4 years ago