@redmunroe/graphql-builder
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

Graphql-Builder

typescript / node.js graphql schema builder in code.

Purpose

We have IaC (Infrastructure as Code) and i needed a way to programatically produce a graphql schema. so I give (SaC) Schema as Code. This repo will allow you to programatically create a graphql schema all through nodejs.

I have plans to expand this to GoLang later.

Install

npm i @RedMunroe/graphql-builder

Import

import Schema from @redmunroe/graphql-builder

Usage

const schema = new Schema();
// Type creation
const user = new Type('User').addField('id', fieldType.STRING, true);
// Input type creation
const userInput = new Input('UserInput').addField('id', fieldType.STRING, true);
schema
  .addInput('UserInput', userInput)
  .addType('User', user)
  .addQuery('getUser', {
    output: schema.getType('User'),
  })
  .addMutation('createUser', {
    input: schema.getInput('UserInput'),
    output: schema.getType('User'),
  });

console.log(schema.compile());

Package Sidebar

Install

npm i @redmunroe/graphql-builder

Weekly Downloads

1

Version

0.0.4

License

MIT

Unpacked Size

23.2 kB

Total Files

34

Last publish

Collaborators

  • redmunroe