Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gql-builder

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gql-builder

Graphql Query Builder

  • 0.0.16
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

NPM Version Build Status Coverage Status

GQL Builder

Programmatically Graphql Query Builder Component

Install Package
npm install gql-builder
Features
  • Simple usage
  • Query support
  • Mutation support
  • Nested fields support
Usage Examples

Query Example 1

String Usage

'query {
    user {
        id
        name
    }
}'

GqlBuilder Usage

const qb =  new GqlBuilder();
qb.addSibling('user',['id', 'name']);
qb.toQueryString();

GqlBuilder Alternative Usage

const qb =  new GqlBuilder();
qb.addSibling({ name:'user', fields:['id', 'name']});
qb.toQueryString();

Query Example 2

String Usage

'query {
    user {
        id
        name
        country {
            code
            name            
        }
    }
}'

GqlBuilder Usage

const qb =  new GqlBuilder();
qb.addSibling('user',['id','name',
  {name:'country', fields:['code', 'name']}]);
qb.toQueryString();

GqlBuilder Alternative Usage

const qb =  new GqlBuilder();
qb.addChild('user', ['id', 'name']).
    addChild('country', ['code', 'name']);
qb.toQueryString();

Query Example 3

String Usage

'query ($id: 'Int') {
    user (id: $id) {
        id
        name
        country {
            code
            name            
        }
    }
}'

GqlBuilder Usage

const qb =  new GqlBuilder();
qb.addSibling('user',['id','name',
  {name:'country', fields:['code', 'name']}],
  {id:'Int'});
qb.toQueryString();

GqlBuilder Alternative Usage

const qb =  new GqlBuilder();
qb.addChild('user', ['id', 'name'], {id: 'Int'}).
    addChild('country', ['code', 'name']);
qb.toQueryString();

Mutation Example 1

String Usage

'mutation ($user: User_Input) {
    createUser (user: $user) {
        id
        name
    }
}'

GqlBuilder Usage

const qb =  new GqlBuilder();
qb.addSibling('createUser', ['id','name'], {user:'User_Input'});
qb.toMutationString();

GqlBuilder Alternative Usage

const qb =  new GqlBuilder();
qb.addSibling({name:'createUser', fields:['id','name'], filters:{user:'User_Input'}});
qb.toMutationString();

Mutation Example 2

String Usage

'mutation ($id: Int, $name: String, $gender: String) {
    updateUser (id: $id, user: {
        name: $name
        gender: $gender
    }) {
        id
        name
        gender
    }
}'

GqlBuilder Usage

const qb =  new GqlBuilder();
qb.addSibling('updateUser', ['id','name','gender'], 
  {
    id: 'Int', 
    user: {name:'String', gender:'String'}
  });
qb.toMutationString();

GqlBuilder Alternative Usage

const qb =  new GqlBuilder();
qb.addSibling({
  name:'createUser', 
  fields:['id','name'], 
  filters: {
             id: 'Int', 
             user: {name:'String', gender:'String'}
           }
});
qb.toMutationString();

Keywords

FAQs

Package last updated on 28 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc