1.0.0-alpha • Published 7 years ago

@jjsoft2018/graphql-harmony v1.0.0-alpha

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

Graphql Harmony

pipeline status coverage report

feature & complete

  • graphql endpoint
  • graphql playground
  • graphql cache
  • net server
  • error handling
  • cache

How to start server

import {GraphqlServer} from './src'
const server = new GraphqlServer()
server.start({
  // see ./src/types.ts>IGraphqlServerOptions
}).then(({address}) => {
  const info = address()
  console.log(`server was started at ${info.address}::${info.port}`)
  server.stop().then(() => {
    console.log('server stopped')
  })
})

How to create query

import {Query, Resolver, Arg} from 'type-graphql'
import {HarmonyError, Err, ErrorGroup, ErrorItem} from './src'

class MyResolverError extends ErrorGroup {
  @Err() justError: ErrorItem = 'just error' as any
}

const myErrors = new MyResolverError()

@Resolver()
class MyResolver {
  @Query()
  async getSomething(@Arg() name: string) {
    if(name === 'bichi'){
      // how to throw error
      throw new HarmonyError(myErrors.justError)
    }
    return name
  }
}

using suggestion

refer to ./exapmles

Options

see src/GraphqlServer/types.ts>IGraphqlServerOptions

docs

yarn docs
# and see files in ./docs