Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lighthouse Model Subscriptions

This library provides an easy solutions for broadcasting generic model changes via Lighthouse GraphQL subscriptions.

Example

In order to make a model subscribable, simply apply the @subscribable directive. This will add a new subscription field for the given model.

type Post @subscribable {
    id: ID!
    title: String!
}

This will result in the following automatically being added to your schema.

enum EventType {
    CREATED
    UPDATED
    DELETED
}

type PostEvent {
    id: ID!
    model: Post
    event: EventType!
}

type Subscription {
    "Subscribe to changes to Posts."
    postModified(
        "If not filled, all event-types will be subscribed to."
        events: [EventType],
        
        "If filled, only the model with this ID will be subscribed to."
        id: ID
    ): PostEvent
}

About

An easy solution to model subscriptions via Lighthouse GraphQL

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages