Giter Site home page Giter Site logo

asmeikal / gql-on-ws-on-saga Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 1.0 358 KB

A client for graphql-ws implemented on top of redux-saga.

License: MIT License

JavaScript 4.68% TypeScript 95.32%
graphql-ws subscription graphql redux-saga gql-on-ws websocket

gql-on-ws-on-saga's Introduction

gql-on-ws-on-saga

npm Builds Code coverage

Turtles all the way down.

This repo is an experiment in how easily can a protocol be implemented using redux-saga as an engine. The protocol in question is the graphql-ws protocol, but only for the client side.

The motivation for this experiment is a lot of frustration with the bugs that plague the subscriptions-transport-ws client implementation, and wanting to have an opinionated client for the graphql-ws protocol.

The implementation is split in three layers:

  • the client, that handles subscriptions (and operations in general), and implements the public API
  • the protocol, that keeps track of subscriptions, routes them through the transport, and sends messages from the transport to the client
  • the transport, that wraps the WebSocket connection

The three layers

The client layer is oblivious to connections and disconnections of the underlying WebSocket (unless it listens to the instrumentation events), while the protocol layer has the responsibility of performing all operations that the client requests, and track them until completion. If the WebSocket fails, it's the protocol responsibility to reconnect the transport, and to re-establish all operations.

Is this efficient? IDK and IDC.

Is this correct? IDK but I hope it is.

Should you use this? At your own risk.

The code in this repo could be modified to create a client for the subscriptions-transport-ws, even though I see no reason to do so, since most of the bugs that plague the protocol affect also the server implementation.

gql-on-ws-on-saga's People

Contributors

asmeikal avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.