micrographql-client
TypeScript icon, indicating that this package has built-in type declarations

2.1.3 • Public • Published

Test statusCodeQL statusDependenies

micrographql-client

Small graphQL client library.

Its nanographql successor with some more features:

  • convert GraphQL query schema to stringify query object
  • support named query
  • support pack variables to query object
  • have options to prevent double stringify variables
  • support fragments

It may be used with HTTP or WAMP transport.

Installation

$ npm install micrographql-client

Usage

var gql = require('micrographql-client')

var query = gql`
  query($name: String!) {
    movie (name: $name) {
      releaseDate
    }
  }
`

try {
  var res = await fetch('/query', {
    body: query({ name: 'Back to the Future' }),
    method: 'POST'
  })
  var json = res.json()
  console.log(json)
} catch (err) {
  console.error(err)
}

API

query = gql(string)

Create a new graphql query function.

processedQuery = query({/*variables*/}, variablesAsObject)

Create a new query object as string that can be sent as application/json to a server.

In case of use another transport set variablesAsObject to true to prevent double stringify variables.

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i micrographql-client

Weekly Downloads

4

Version

2.1.3

License

MIT

Unpacked Size

7.67 kB

Total Files

7

Last publish

Collaborators

  • meettya