are there concrete examples on how to use `withFil...
# prisma-whats-new
t
are there concrete examples on how to use
withFilter
in conjunction with
ctx.db.subscription
?
ctx.db.subscription.link
returns a Promise to AsyncIterator - so
await
for that gets me closer, but using the result in
withFilter
yields and error still
my naive attempt looks something like this
Copy code
subscribe: (parent, args, ctx, info) => withFilter(() => ctx.db.subscription.link(
    { },
    info,
  ), (payload, variables) => {
      return true
  })
but subscribed playgrounds aren't receiving anything
here is something that does seem to work, but I am at a loss as to why the syntax is so different than I would have expected
Copy code
subscribe: async (parent, args, ctx, info) => {
    const subscription = await ctx.db.subscription.link(
      { },
      info,
    )

    filteredSubscription =  withFilter( () => subscription , (payload, variables) => {
      return true
    })

    return filteredSubscription()
  }
w
Where is
withFilter
coming from?
when I wanted to filter my subscription using prisma-bindings, I did it similar to how the
.query
worked:
Copy code
subscribe: async (parent, args, ctx, info) => {
      const fullAuth0Id = await getAuth0Id(ctx, true)
      return ctx.db.subscription.user({ 
        where: {
          node: {
            fullAuth0Id
          } 
        } 
      }, info);
    },
t
const {withFilter} = require('graphql-yoga')
in my case I was filtering messages based on a friendship list - which may not have a direct relationship with the user
w
You can use ctx.db to query against anything, it doesn't have to relate to the resolver you're in. You can use an
ctx.db.exists
call, and use the `every`/`some`/`none` conditional queries to verify friendship requirements
t
in this use case it's data not stored in the db - it's retrieved from another service