Licence
MIT
Version
1.2.3-alpha
Deps
15
Size
1.8 MB
Vulns
4
Weekly
0
Graphql Harmony
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/GraphqlServer/__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()
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