0.1.1 • Published 5 years ago

scaffoldql v0.1.1

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

npm version

ScaffoldQL

ScaffoldQL is a JavaScript library that is used to generate objects using scaffolds.

Inspired by GraphQL

Installation:

npm install --save scaffoldql

Usage:

Simple Usage:

const { init } = require('scaffoldql')

const queryString = `
{
  parent {
    child {
      grandchild
    }
    anotherChild
  }
  anotherParent
}`

const store = init()

console.log(store.scaffold(queryString))

/*
{
  parent: {
    child: {
      grandchild: null
    },
    anotherChild: null
  },
  anotherParent: null
} 
 */

With Types:

const { init } = require('scaffoldql')

const queryString = `
{
  name: String
  friends: Array
  sex: String
}
`

const store = init()

console.log(store.scaffold(queryString))
/*
{
  name: '',
  friends: [],
  sex: ''
}
*/

By Defining Schemas

const { init } = require('scaffoldql')

const queryString = `
define Person {
  name: String
  friends: Array
  sex: String
}
`

const store = init()

store.registerSchema(queryString)

console.log(store.scaffoldSchema('Person'))

/*
{
  name: '',
  friends: [],
  sex: ''
}
*/