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

graphql-http

Package Overview
Dependencies
Maintainers
3
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-http

A GraphQL client for executing GraphQL queries over HTTP.

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
272K
decreased by-14.62%
Maintainers
3
Weekly downloads
 
Created
Source

graphql-http

A GraphQL client for executing queries over HTTP.

DISCLAIMER

This library is not suitable for production use. If you're looking for a client with similar functionality, see Lokka. It has much more support and is much more robust.

Usage

import { GQLClient } from 'graphql-http';

const client = GQLClient('http://localhost:3000', {
  fetch: {
    // anything passed here is merged with
    // the options passed to fetch()
    credentials: true,
    headers: {
      'X-Requested-With': 'XMLHttpRequest'
    }
  }
});

Queries

client.query(`
  query ($id: RecordID!) {
    user(id: $id) {
      id
      name
    }
  }
`, { id: 1234 }).then((result) => {
  console.log(result.data.user);
  // => { id: 1234, name: ... }
});

Mutations

client.mutate(`
  mutation ($id: RecordID!, $name: String!) {
    updateUser(input: {id: $id, name: $name}) {
      user {
        id
        name
      }
    }
  }
`, { id: 1234, name: 'Danny' }).then((result) => {
  console.log(result.data.user);
  // => { id: 1234, name: 'Danny' }
});

Keywords

FAQs

Package last updated on 04 Apr 2017

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