Skip to content

Example Request: Subscriptions with RedisPubSub #1340

@JoJ123

Description

@JoJ123

Hey,
I would like to request an example of GraphQL Yoga Subscriptions with RedisPubSub and asynchronous filtering.

We managed to migrate from ApolloServer to Yoga, but we still have to rely on the withFilter Function from apollo. This is working fine, but it would be easier / cleaner if we could directly make use filter function from GraphQL Yoga. Like described here: https://www.graphql-yoga.com/docs/features/subscriptions#filter-and-map-values

import { withFilter } from 'apollo-server-express';
{
  Subscription: {
    testSub: {
      subscribe: withFilter(
        (root: any, args: any, context: GraphQLModules.Context) =>
          context.injector.get(testModuleConfig).pubsub.asyncIterator("TEST_TOPIC"),
        (root, args, context: GraphQLModules.Context) => {
          // Here we can filter
          return new Promise(resolve => resolve(true / false));
        }
      ),
    },
  },
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions