0.7.2 • Published 7 years ago

ez-ql v0.7.2

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

Ez-ql

npm npm

Easy to use GraphQL client for front-end development.

Installation

Installing with npm:

npm install --save ez-ql

yarn:

yarn add ez-ql

Usage

import Ez from 'ez-ql'

After installing and importing the package, there are only two simple calls that need to be used for full functionality after instantiating a new Ez object...

const ez = new Ez({
  uri: 'http://127.0.0.1:8080/graphql', // The url|uri of the target API
  headers: {
    'Content-Type': 'application/json'
  }
})

The options object passed to the constructor looks for two properties, the url|uri and a headers object. Creating additional headers is optional and if disregarded will default to 'Content-Type': 'application/json' as the sole header. If the url|uri property in the constructor options is just set, it defaults to http://localhost:8080/graphql.

The first of the two calls is the ES6 template string literal tag ql...

ez.ql`
  {
    lot(number: 5) {
      totalSpaces
      permits
      closed
    }
  }
`.then(...).catch(...)

Its alternative for when you have a pre-build string that represents your GraphQL query, there is a non-literal-tag function that can be used.

const query = `
  {
    lot(number: 5) {
      totalSpaces
      permits
      closed
    }
  }
`

ez.pql(query)
  .then(...)
  .catch(...)

Both ql and pql returns promises to be handled as needed.

License

MIT License

Copyright (c) 2017 Matthew Callens

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0.7.2

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.1

7 years ago

0.6.0

7 years ago

0.5.2

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago