Skip to content

frux/graphin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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(data => {
		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

Param Type Description
endpoint string GraphQL endpoint URL
options ``object undefined``
options.cache number Cache TTL in ms
options.fetch object Fetch options
options.verbose boolean Verbose mode. Default false
fetcher ``function undefined``

graphin.query(url, options) ⇒ Promise

Makes GraphQL Query

Param Type Description
url string GraphQL Query
requestOptions ``object undefined``
requestOptions.cache number Cache TTL in ms
requestOptions.fetch object Fetch options
requestOptions.verbose boolean Verbose mode. Default false

graphin.getQueryURL(query) ⇒ string

Converts GraphQL query to URL

Param Type Description
query string GraphQL Query

About

💧Javascript isomorphic GraphQL client

Resources

Stars

Watchers

Forks

Packages

No packages published