8000 GitHub - tjmehta/graphql-fetch: Thin GraphQL client powered by fetch.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

tjmehta/graphql-fetch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

graphql-fetch Build Status js-standard-style

Thin GraphQL client powered by fetch.

Installation

npm i --save graphql-fetch

Usage

var fetch = require('graphql-fetch')('http://domain.com/graphql')

var query = `
  query q (id: String!) {
    user(id: $id) {
      id,
      email,
      name
    }
  }
`
var queryVars = {
  id: 'abcdef'
}
var opts = {
  // custom fetch options
}

/**
 * @param  {Query} query graphql query
 * @param  {Object} [vars]  graphql query args, optional
 * @param  {Object} [opts]  fetch options, optional
 */
fetch(query, queryVars, opts).then(function (results) {
  if (results.errors) {
    //...
    return
  }
  var user = result.data.user
  //...
})

Notes

  • Uses isomorphic-fetch under the hood, which makes fetch, Headers, Request, and Response globally available.

License

MIT

About

Thin GraphQL client powered by fetch.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
0