graphql-got

Convenience wrapper for got to interact with GraphQL

  • Owner: kevva/graphql-got
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

graphql-got Build Status

Convenience wrapper for got to interact with GraphQL

A lightweight alternative to apollo-client and relay.

Install

$ npm install graphql-got

Usage

const graphqlGot = require('graphql-got');

const query = `{
	unicorn(name: "Foo Bar") {
		id
		name
	}
}`;

graphqlGot('api.graphql.unicorn', {query}).then(response => {
	console.log(response.body);
	/*
	{
		unicorn: {
			id: 0,
			name: 'Foo Bar'
		}
	}
	*/
});

API

Same as got, but with some additional options below. URLs without protocol will be prepended with https://.

query

Required
Type: string

The query to send to GraphQL.

variables

Type: Object

Variables to be used in your query. Read more here.

operationName

Type: string

If your query contains multiple operations, this option is required to decide which operation to run.

token

Type: string

If defined, an Authorization header with bearer ${TOKEN} will be sent.

License

MIT © Kevin Mårtensson

Main metrics

Overview
Name With Ownerkevva/graphql-got
Primary LanguageJavaScript
Program languageJavaScript (Language Count: 1)
Platform
License:MIT License
所有者活动
Created At2017-09-12 17:35:13
Pushed At2018-03-14 19:41:13
Last Commit At2018-03-14 20:40:52
Release Count3
Last Release Namev0.1.2 (Posted on 2018-03-14 20:40:52)
First Release Namev0.1.0 (Posted on 2017-09-12 19:48:45)
用户参与
Stargazers Count104
Watchers Count3
Fork Count5
Commits Count10
Has Issues Enabled
Issues Count3
Issue Open Count3
Pull Requests Count2
Pull Requests Open Count0
Pull Requests Close Count0
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private