0.3.0 • Published 7 years ago

@gsox/schema v0.3.0

Weekly downloads
1
License
MIT
Repository
-
Last release
7 years ago

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

7 years ago

0.2.2

7 years ago

0.2.0

7 years ago

0.1.18

7 years ago

0.1.16

7 years ago

0.1.15

7 years ago

0.1.14

7 years ago

0.1.12

7 years ago

0.1.11

7 years ago

0.1.10

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago