Socket
Socket
Sign inDemoInstall

@increments/graphql-client

Package Overview
Dependencies
1
Maintainers
7
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @increments/graphql-client

A lightweight GraphQL client


Version published
Weekly downloads
0
decreased by-100%
Maintainers
7
Install size
181 kB
Created
Weekly downloads
 

Changelog

Source

[0.3.0] - 2018-04-18

Changed

  • Change distribution file format

Readme

Source

@increments/graphql-client

NPM version Build Status Maintainability Test Coverage Stable Release Size

A lightweight GraphQL client which bundles sequence of queries into a single HTTP request.

Installation

If your project is using npm, you can install @increments/graphql-client package by npm command:

npm install --save @increments/graphql-client
# or
yarn add @increments/graphql-client

Distribution files

  • dist/graphql-client.js - ES5 / IIFE version of this package. This version exports itself to window.GraphQLClient.
  • dist/graphql-client.min.js - Minified version.

Size

Packagemin.js.gz size
@increments/graphql-client800 B
apollo-client (apollo-client-preset + graphql-tag + graphql)29 KB

Synopsis

import { GraphQLClient } from "@increments/graphql-client"

const client = new GraphQLClient({
  /** How long the client wait before invoking batch request in msec. */
  wait: 50, // defualt value

  /**
   * Batch request handler.
   *
   * @param {string} query - Bundled GraphQL query string.
   * @param {Object} variables - Bundled variables.
   * @param {Function} resolve - Callback for successful response.
   * @param {Function} reject - Callback for failure response.
   */
  handle(query, variables, resolve, reject) {
    // Send a HTTP request to your GraphQL server in your favorite way.

    // Sample:
    axios.post("/graphql", { query, variables })
      .then(response => resolve(response.data)
      .catch(reject)
  }
})

// The handle function will be executed once, even though client.query is called twice.
Promise.all([
  client.query("viewer { name }"),
  client.query(`
    repository(owner: $owner, name: $name) {
      url
    }`,
    {
      owner: {
        type: "String!",
        value: "increments",
      },
      name: {
        type: "String!",
        value: "graphql-client",
      },
    }
  ),
]).then((
  viewer,
  repository,
) => {
  console.log(viewer.data.viewer.name)
  console.log(repository.data.repository.url)
})

FAQs

Last updated on 18 Apr 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc