@redmunroe/graphql-builder
v0.0.4
Published
nodejs graphql schema builder in code
Downloads
7
Maintainers
Readme
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());