0.0.14 • Published 8 years ago

graphin v0.0.14

Weekly downloads
2
License
MIT
Repository
github
Last release
8 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

8 years ago

0.0.13

8 years ago

0.0.12

8 years ago

0.0.11

8 years ago

0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago