Version: Next

Subscriptions

Subscriptions are divided into three groups of changes: Create, Update and Delete.

  • new<Type>: subscribe to the Create mutation event.
  • updated<Type>: subscribe to the Update mutation event.
  • deleted<Type>: subscribe to the Delete mutation event.

Graphback generates a subscription handler and filter input for each CRUD mutation field to let you subscribe to mutation events and receive real-time updates.

""" @model """
type Note {
id: ID!
title: String!
likes: Int
}
input NoteSubscriptionFilter {
id: IDInput
title: StringInput
likes: IntInput
and: [NoteSubscriptionFilter!]
or: [NoteSubscriptionFilter!]
not: NoteSubscriptionFilter
}
type Subscription {
newNote(filter: NoteSubscriptionFilter): Note!
updatedNote(filter: NoteSubscriptionFilter): Note!
deletedNote(filter: NoteSubscriptionFilter): Note!
}

Examples#

Subscribing to a create event on Note:

subscription {
newNote {
id
title
likes
}
}

You can apply filters to the subscription like so:

subscription {
newNote(filter: {
likes: {
gt: 100
},
title: {
contains: 'football'
}
}) {
id
title
likes
}
}

Subscribing to a update event on Note:

subscription {
updatedNote {
id
title
likes
}
}

You can apply filters to the subscription like so:

subscription {
updatedNote(filter: {
likes: {
gt: 100
},
title: {
contains: 'football'
}
}) {
id
title
likes
}
}

Subscribing to a delete event on Note:

subscription {
deletedNote {
id
title
likes
}
}

You can apply filters to the subscription like so:

subscription {
updatedNote(filter: {
likes: {
gt: 100
},
title: {
contains: 'football'
}
}) {
id
title
likes
}
}