@gsox/schema

decorators, types, and builders for describing data

Stats

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

Readme

gsox-schema

decorators, types, and builders for describing data

installation

npm i @gsox/schema

Decorators

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

@Type()
class Alert {
      @Field('Int')
      id:number;

      @Field()
      data: string;
}

@Type()
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.