@gsox/schema
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

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])

Dependencies (2)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @gsox/schema

    Weekly Downloads

    3

    Version

    0.3.0

    License

    MIT

    Unpacked Size

    40.4 kB

    Total Files

    51

    Last publish

    Collaborators

    • amerani