New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gql-api-client

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gql-api-client

Graphql Client Library

  • 0.0.11
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

NPM Version Build Status Coverage Status

Graphql API Client

Simple usage and lightweight graphql api client. Returning promise type.

Install Package
npm install gql-api-client
Usage Examples
const request =  new GqlClient(
    {
       url: 'http://localhost:4000/graphql',
       query: `{                                   
                  user(id:1) {
                     id 
                     name
                     email                                                                          
                  }                      
               }`
    }
);
request.send().then((response)=>{
  console.log(response);
  /* Output
    {
      data: {..},
      status: ..,
      statusText: ..,
      headers: {..}
    }
   */
});

const request =  new GqlClient();
request.url = 'http://localhost:4000/graphql';
request.query =`{                                   
                  user(id:1) {
                    id 
                    name
                    email                                                                          
                  }                      
                }`;
request.send().then((response)=>{
  console.log(response);  
});

Pass parameters

const request =  new GqlClient();
request.url = 'http://localhost:4000/graphql';
request.query =`query ($id: Int!) {                                   
                  user(id:$id) {
                    id 
                    name
                    email                                                                          
                  }                      
                }`;
request.send({id:1}).then((response)=>{
  console.log(response);  
});

Bearer token support

const request =  new GqlClient();
request.url = 'http://localhost:4000/graphql';
// Bearer token
request.token = 'TestToken';
request.query =`query ($id: Int!) {                                   
                  user(id:$id) {
                    id 
                    name
                    email                                                                          
                  }                      
                }`;
request.send({id:1}).then((response)=>{
  console.log(response);  
});

Add custom headers

const request =  new GqlClient();
request.url = 'http://localhost:4000/graphql';
request.headers = {'authorization':'Token'};
request.query =`query ($id: Int!) {                                   
                  user(id:$id) {
                    id 
                    name
                    email                                                                          
                  }                      
                }`;
request.send({id:1}).then((response)=>{
  console.log(response);  
});

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