jsgql
Javascript to graphql-tag/gql
Last updated 3 years ago by ceej .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install jsgql 
SYNC missed versions from official npm registry.

jsgql

<q>Javascript to graphql-tag/gql</q>

Build Status Coverage Status Downloads License

Install

yarn add jsgql@latest

Description

Converts a javascript object to a graphql-tag/gql object.

Use

import jsgql from 'jsgql'

const testGql = {
  type: 'query',
  name: 'test',
  method: 'testMethod',
  methodArgs: {
    last: 1,
    filter: {
      barIn: ['test'],
      foo: {__variable__: 'foo'},
      baz: {__type__: 'CREATED'},
    },
  },
  variables: {
    id: 1,
    foo: 'bar',
  },
  types: {
    bar: 'Baz',
  },
  fields: [
    'id',
    ['foo', [
      'id', 'bar',
    ]],
  ],
}

console.log(jsgql(testGql))
// {
//   "kind": "Document",
// ...

The string that's created by the above object and sent to graphql-tag/gql

query name($id: ID!, $foo: Baz!, $bar: String!) {
  testMethod(id: $id, foo: $foo, bar: $bar, last: 1, filter: {
    barIn: ["test"], foo: $foo, baz: CREATED
  }) {
    id
    foo {
      id
      bar
    }
  }
}

Current Tags

  • 1.0.4                                ...           latest (3 years ago)

6 Versions

  • 1.0.4                                ...           3 years ago
  • 1.0.3                                ...           3 years ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
  • 0.0.1                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (25)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |