0.0.14 • Published 9 years ago

graphin v0.0.14

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

Graphin Build Status XO code style

Isomorphic JavaScript GraphQL client

import Graphin from 'graphin';

const graphin = new Graphin('https://my.graphql.endpoint.com');

// Simple GraphQL query
graphin.query(`{
	userList {
		login
		name
		email
	}
}`)
	.then(list => {
		console.log(data.userList);
	});


// List of users cached for a minute
graphin.query(`{
	photoList {
		id
		url
		description
		width
		height
	}
}`, {cache: 60000})
	.then(data => {
		console.log(data.photoList);
	});

// Simple GraphQL mutation
graphin.query(`mutation {
	updatePhoto(id: 100500, description: "Photo of a real Unicorn!") {
		id
	}
}`);

API

new Graphin(endpoint, options, fetcher) ⇒ Graphin

ParamTypeDescription
endpointstringGraphQL endpoint URL
optionsobject|undefinedGraphin general options. Affect all requests. Default {}
options.cachenumberCache TTL in ms
options.fetchobjectFetch options
options.verbosebooleanVerbose mode. Default false
fetcherfunction|undefinedFetch function (url, options) => Promise. Default fetch

graphin.query(url, options) ⇒ Promise

Makes GraphQL Query

ParamTypeDescription
urlstringGraphQL Query
requestOptionsobject|undefinedRequest options. Affect only this request. Merge with general options. Default {}
requestOptions.cachenumberCache TTL in ms
requestOptions.fetchobjectFetch options
requestOptions.verbosebooleanVerbose mode. Default false

graphin.getQueryURL(query) ⇒ string

Converts GraphQL query to URL

ParamTypeDescription
querystringGraphQL Query
0.0.14

9 years ago

0.0.13

9 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago