decorators, types, and builders for describing data


0.3.03 years ago3 years agoMinified + gzip package size for @gsox/schema in KB



decorators, types, and builders for describing data


npm i @gsox/schema


import { Type, Field } from "@gsox/schema"

class Alert {

      data: string;

class MessageType { ... }

TypeScript Decorators
JavaScript Decorators

AST Builders (wip)

import { TypeNode, FieldNode } from "@gsox/schema"

const alertTypeNode = new TypeNode('Alert', [
      new FieldNode('id', 'Int'),
      new FieldNode('data', 'String')

GraphQL (wip)

const typeDef = `
      type Alert {
            id: Int
            data: String

Schema Injection

inject shared client and server types or graphql type definitions

const inject: {new ()}[]      //constructor functions
            | {}[]            //objects
            | string[] =
            Notification,     // class with
            Message,          // schema
            new Alert(),      // decorators

            //or typedef
            `message {
                  type: String
// client.js
import { createClient } from "@gsox/client"

const client = createClient(options)
client.subscribe([...inject], observer)
// server.js
import { applyMiddleware } from "@gsox/server"

const app = express()
const server = applyMiddleware(app, [...inject])

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.