All Projects → CodeCommission → Subscriptions Transport Sse

CodeCommission / Subscriptions Transport Sse

Licence: mit
A Server-Side-Events (SSE) client + server for GraphQL subscriptions

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Subscriptions Transport Sse

Graphql Ws
Coherent, zero-dependency, lazy, simple, GraphQL over WebSocket Protocol compliant server and client.
Stars: ✭ 398 (+623.64%)
Mutual labels:  graphql, apollo, subscriptions, server, transport, client
Aws Lambda Graphql
Use AWS Lambda + AWS API Gateway v2 for GraphQL subscriptions over WebSocket and AWS API Gateway v1 for HTTP
Stars: ✭ 313 (+469.09%)
Mutual labels:  graphql, apollo, subscriptions
Graphql Shield
🛡 A GraphQL tool to ease the creation of permission layer.
Stars: ✭ 3,121 (+5574.55%)
Mutual labels:  graphql, apollo, server
Omdb Graphql Wrapper
🚀 GraphQL wrapper for the OMDb API
Stars: ✭ 45 (-18.18%)
Mutual labels:  graphql, apollo, server
React Apollo Decorators
Better decorators for Apollo and React
Stars: ✭ 39 (-29.09%)
Mutual labels:  graphql, apollo
Crypto Grommet
Crypto and equities app
Stars: ✭ 39 (-29.09%)
Mutual labels:  graphql, apollo
Laravel Vuejs.com
Laravel and VueJs Blog, using Laravel nova, GraphQL, NuxtJs, Apollo and ...more
Stars: ✭ 54 (-1.82%)
Mutual labels:  graphql, apollo
Apollo Redux Form
Redux forms powered by Apollo
Stars: ✭ 52 (-5.45%)
Mutual labels:  graphql, apollo
Link state demo
🚀 Demonstrate how to support multiple stores in Apollo Link State
Stars: ✭ 30 (-45.45%)
Mutual labels:  graphql, apollo
Go Raknet
An idiomatic Go library implementing a basic version of the RakNet protocol.
Stars: ✭ 40 (-27.27%)
Mutual labels:  server, client
Apollo Invalidation Policies
An extension of the Apollo 3 cache with support for type-based invalidation policies.
Stars: ✭ 55 (+0%)
Mutual labels:  graphql, apollo
React Boilerplate
⚛ The stable base upon which we build our React projects at Mirego.
Stars: ✭ 39 (-29.09%)
Mutual labels:  graphql, apollo
Graphql
An implementation of GraphQL for Go / Golang
Stars: ✭ 8,176 (+14765.45%)
Mutual labels:  graphql, subscriptions
A Pop
🎶 HD Music Streaming and Sharing Web App
Stars: ✭ 55 (+0%)
Mutual labels:  graphql, apollo
Graphql Modules
Enterprise Grade Tooling For Your GraphQL Server
Stars: ✭ 962 (+1649.09%)
Mutual labels:  graphql, apollo
Graphql Apq
🎯 Automatic persisted queries (APQ) for any GraphQL server.
Stars: ✭ 43 (-21.82%)
Mutual labels:  graphql, apollo
Graphql Upload
Middleware and an Upload scalar to add support for GraphQL multipart requests (file uploads via queries and mutations) to various Node.js GraphQL servers.
Stars: ✭ 1,071 (+1847.27%)
Mutual labels:  graphql, apollo
Graphql Advanced Projection
Fully customizable Mongoose/MongoDB projection generator.
Stars: ✭ 46 (-16.36%)
Mutual labels:  graphql, apollo
Graphql Modules
⚠️ [DEPRECATED] GraphQL module library for Apollo.
Stars: ✭ 53 (-3.64%)
Mutual labels:  graphql, apollo
Zeus
A high performance, cross-platform Internet Communication Engine. Developed with native socket API. Aim at handling millions of concurrent connections.
Stars: ✭ 30 (-45.45%)
Mutual labels:  server, client

subscriptions-transport-sse

A GraphQL Server-Side-Events (SSE) server and client to facilitate GraphQL subscriptions.

That's an API compatible SSE transport implementation of subscriptions-transport-ws.

Example

Getting Started

Using Yarn:
$ yarn add subscriptions-transport-sse

Or, using NPM:
$ npm install --save subscriptions-transport-sse

ExpressJS Server

Starting with the server, create a new simple SubscriptionsManager, with a PubSub implementation:

import { SubscriptionManager, PubSub } from 'graphql-subscriptions'

const schema = {} // Replace with your GraphQL schema object
const pubsub = new PubSub()

const subscriptionManager = new SubscriptionManager({
  schema,
  pubsub
})

Now, use your subscriptionManager, and create your SubscriptionServer:

const express = require('express')
const app = express()
const expressGraphQLSubscriptionsSSETransport = require('subscriptions-transport-sse')

expressGraphQLSubscriptionsSSETransport.SubscriptionServer({
  onSubscribe: (msg, params) => Object.assign({}, params, { context: { loaders: loaders(), } }),
  subscriptionManager: graphqlSubscriptions.subscriptionManager,
}, {
  express: app,
  path: '/subscriptions',
})

app.listen(SERVICE_PORT, () => console.log(`Listen on ${SERVICE_PORT}`))

Apollo Client (Browser)

For client side, we will use SubscriptionClient, and we also need to extend our network interface to use this transport for GraphQL subscriptions:

import { SubscriptionClient, addGraphQLSubscriptions } from 'subscriptions-transport-sse'
const httpClient = createNetworkInterface({uri: `https://my-graphql.example.com/graphql`})
const sseClient = new SubscriptionClient(`https://my-graphql.example.com/subscriptions`)
const apolloClient = new ApolloClient({networkInterface: addGraphQLSubscriptions(httpClient, sseClient)})

Now, when you want to use subscriptions in client side, use your ApolloClient instance, with subscribe or subscribeToMore (according to your apollo-client usage):

apolloClient.subscribeToMore({
    document: gql`
        subscription onNewItem {
            newItemCreated {
                id
            }
        }`,
    variables: {},
    updateQuery: (prev, {subscriptionData}) => {
        return; // Modify your store and return new state with the new arrived data
    }
});

API

TBD, but compatible with subscriptions-transport-ws.

Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker.

License

This project is licensed under the MIT license. See the LICENSE file for more info.

Thanks

You like this subscriptions-transport-sse and you want to see what coming next? Follow me on Twitter @mikebild.

Enjoy!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].