6.114.11 • Published 2 years ago

@magloft/tsed-graphql-ws v6.114.11

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

@magloft/tsed-graphql-ws allows you to enable GraphQL Subscription support in your project.

This package uses graphql-ws to bridge a Websocket server with the existing TS.Ed http server. Once set up, you can start using type-graphql Subscriptions.

Installation

First, make sure you install @tsed/typegraphql.

Next, install the GraphQL WS module:

npm install --save @magloft/tsed-graphql-ws
# or
yarn add @magloft/tsed-graphql-ws

Import @magloft/tsed-graphql-ws in your Server, and configure your instance:

import { Configuration } from '@tsed/common'
import '@magloft/tsed-graphql-ws'

@Configuration({
  graphqlws: {
    instance: 'default'
  }
})
export class Server {}

This instance needs to match your graphql instance ID

Usage

Once installed, websocket server & subscription support will bootstrap automatically when you start your server. The following log message should indicate that you're good to go:

[INFO ] [TSED] - [graphql-ws] GraphQL Subscriptions enabled for instance 'default'

License

The MIT License (MIT)

Copyright (c) 2016 - 2018 Romain Lenzotti

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.