Skip to content

a node.js based alternative to firebase cloud firestore

Notifications You must be signed in to change notification settings

asheghi/waterbase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WaterBase

an attempt to create an alternative for CloudFlare realtime database, Cloud FireStore

add `Subscription` to Keystone.js CMS GraphQL api

an Exmaple for Vue.js Apollo Client is also included in the /example/vue-client directory.

Usage:

Step 1:

you need to go with the custom http server mode with keystone.js. then call initSubscriptionServer with your http server and keystone object.

Example:

keystone
    .prepare({
        apps: apps,
        dev: process.env.NODE_ENV !== 'production',
    })
    .then(async ({middlewares}) => {
        await keystone.connect();
        const app = express();
        app.use(middlewares)
        const httpServer = http.createServer(app);
        
        httpServer.listen(3000, () => {
                //first step
                initSubscriptionServer(httpServer,keystone);
        })
});

Step 2:

to add Model Subscription you need to call addModelToSubscription method with your list.

Example:

const model = {
    fields: {
        name: {
            type: Text,
            isRequired: true,
        },
        //...
    },
};

const list = keystone.createList('Book', model);
//second step
addModelToSubscription({keystone, list});

Step 3:

now you can listen to subscriptions in your GraphQL api.

Screenshot-from-2021-01-21-14-08-34

Example:

subscription {
    book : anyBookChange{
        id
        name
        author
        date
    }
}

About

a node.js based alternative to firebase cloud firestore

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages