graohql-js-query

a way to make a graphql query in js style

Usage no npm install needed!

<script type="module">
  import graohqlJsQuery from 'https://cdn.skypack.dev/graohql-js-query';
</script>

README

intro

Graphql JS Query

Js style Graphql Query

Build Status Codecov

How to use

import query from './src'
const result = query('user')({name: 'bichi'})(
  'id', 'name', 'age'
).toString()
// result = user(name:"bichi"){id,name,age}
import query from './src'
const result = query('my', 'user')({name: 'bichi'})(
  'id', 'name', 'age'
).toString()
// result = my:user(name:"bichi"){id,name,age}
import query from './src'
const result = query('user')({name: 'bichi'})(
  'id', 'name', 'age', {
    items: ['cookie', 'jam', {candy: ['red', 'blue']}]
  }
).toString()
// result = user(name:"bichi"){id,name,age,items{cookie,jam,candy{red,blue}}}
import query from './src'
const result = query('user')({name: 'bichi', friends: [
  {name: 'ann'},
  {name: 'tom'}
]})(
  'id', 'name', 'age'
).toString()
// result = user(name:"bichi",friends:[{name:"ann"},{name:"tom"]){id,name,age}