GithubHelp home page GithubHelp logo

apollo-postgraphile-subscription-demo's Introduction

Apollo-PostGraphile-Subscription-Demo

Using PostGraphile with Apollo enables a lot of freedom than just run a PostGraphile server. (For example, apollo plugins, apollo studio, middlewares, apollo playground etc). This repo runs apollo with postgraphile, and add basic model subscription to the schema.
For a table users (type User) UserAdded, UserUpdated(id:Int), UserUpdatedAll, UserDeleted are created for the subscription endpoints.

Motivation

PostGraphile itself is capable of subscription, but you have to run it as library, (start postgraphile server), this capability is lost when you "use PostGraphile as schema" and put in Apollo Server. For good reasons, there are times that you would like to utilize some ApolloServer's ability. This is to demo how to systematically setup the subscription for every table and use ApolloServer + graphql-ws as subscription server.

SubProblem this repo try to solve: Performance on broadcast.

The Graphql subscription actually execute the subscription query when it receives the trigger, this means in a large server with 1000 clients subscribed to UserAdded(just an example), when this event is triggered, there will be at least 1000 SQL queries executed for each client. This is definitely a performance pain point and should be resolved. This repo demo a solution. A detailed explaination about this demo can be found here

Install

clone this repo and add a .env file in root directoy with

DATABASE_URL=postgres://... # postgresql connection string

Then run yarn install and yarn run start.

apollo-postgraphile-subscription-demo's People

Contributors

hansololai 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.