@zmartbag.com/graphql-query
TypeScript icon, indicating that this package has built-in type declarations

0.4.1 • Public • Published

GraphQL Query wrapper

Installation

npm i @zmartbag.com/graphql-query

Usage

import { GraphQLQuery } from '/path/to/@zmartbag.com/graphql-query/index.js';

const graphQLQuery = new GraphQLQuery({
	fetch, // Or import node-fetch if on server
	graphqlUrl: 'https://domain/graphql',
	log: {
		silly: (msg) => '', // console.log(msg),
		debug: (msg) => '', // console.log(msg),
		verbose: (msg) => console.log(msg),
		info: (msg) => console.info(msg),
		warn: (msg) => console.warn(msg),
		error: (msg) => console.error(msg),
	}
});

graphQLQuery.run({ query: 'query { foo { bar }}' }).then(result => {
	// result will be a js object from the JSON data obtained by the query
}).catch(err => {
	throw err;
});

Version history

  • 0.4.0 - ESM and CJS builds in parallel
  • 0.2.0 - Changed gatewayUrl to graphqlUrl
  • 0.1.4 - Seriously better error reporting
  • 0.1.3 - Fixed broken code in last release...
  • 0.1.2 - Better error reporting when non-JSON returns from GraphQL remote

Readme

Keywords

none

Package Sidebar

Install

npm i @zmartbag.com/graphql-query

Weekly Downloads

2

Version

0.4.1

License

UNLICENSED

Unpacked Size

12.4 kB

Total Files

6

Last publish

Collaborators

  • raols
  • lilleman
  • filipjohansson