Skip to content
/ scaffold Public

A library that is used to generate object blueprints. Inspired by graphql, powered by JavaScript.

License

Notifications You must be signed in to change notification settings

js-ql/scaffold

Repository files navigation

THIS PROJECT IS NOT ACTIVELY MAINTAINED

JSQL LogoScaffold

npm version

Scaffold is a JavaScript library that is used to generate objects using templates inspired from GraphQL.

Installation

npm install --save @js-ql/scaffold

Usage

Simple Usage

const { scaffold } = require('@js-ql/scaffold')

const queryString = `
{
  name
  age
}`

console.log(scaffold(queryString))

/*
{
  name: null,
  age: null
}
 */

With Types

const { scaffold } = require('@js-ql/scaffold')

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


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

By Defining Schemas

const { Registry } = require('@js-ql/scaffold')

const queryString = `
define Person {
  name: String
  friends: Array
}
`
// Initial Registration

Registry.register(queryString)

.
.
.

// When you need it

console.log(Registry.scaffold('Person'))

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

Multiple Schemas

const { Registry } = require('@js-ql/scaffold')

const queryString = `
  define Friend {
    name
    age
  }
  define Person {
    name: String
    friends: Array
    bestFriend: Friend
  }`


Registry.register(queryString)

.
.
.

console.log(Registry.scaffold('Person'))

/*
{
  name: '',
  friends: [],
  bestFriend: {
    name: null,
    age: null
  }
}
*/

Note: Make sure that schemas that you want to use inside another schema are defined before you use it.

About

A library that is used to generate object blueprints. Inspired by graphql, powered by JavaScript.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published