graphile / graphile/crystal

Filtering of `listen()`

Open
#2,016 2 comments 0 reactions 1 assignee Claimed by @1mehal View on GitHub
✨ feature 🤩 good-first-bug
Dominant language
TypeScript
Stars
12.9k
Forks
625
Avg merge
5h 23m
Merged PRs (30d)
24

Description

From [discussion on Discord](https://discord.com/channels/489127045289476126/498852330754801666/1227546560699830345):

The main challenge I think will be coming up with the API that's suitable for everyone. But to start with, I'd copy the whole of the `listen` step into your own codebase, give it a new name (`filteredListen` or similar), then make the following changes:

1. Accept a filter function in the constructor:

https://github.com/graphile/crystal/blob/b82a080dc1f7826863c993746e70bbabb765a863/grafast/grafast/src/steps/listen.ts#L42-L51
3. Apply this filter function to the stream coming from `pubsub.subscribe(topic)`:

https://github.com/graphile/crystal/blob/b82a080dc1f7826863c993746e70bbabb765a863/grafast/grafast/src/steps/listen.ts#L89

`pubsub.subscribe(topic)` returns (potentially the promise to) an async iterable:

https://github.com/graphile/crystal/blob/b82a080dc1f7826863c993746e70bbabb765a863/grafast/grafast/src/interfaces.ts#L660-L662

So you need to apply filtering to that async iterable by building a new async iterable that skips over values you don't want.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.