Prisma1: Subscription filter seems doesn't work for specific field

Created on 17 Feb 2019  路  3Comments  路  Source: prisma/prisma1

Hey Guys!

I think, there is a big issue in the subscription filtering.

I checked this page(https://www.prisma.io/docs/prisma-client/features/realtime-JAVASCRIPT-rsc8/i), and tried to create the endpoint to subscribe to a room. only when a new message is posted on the room, the subscription endpoint returns the message, but I got nothing from it.

when I changed { mutation_in: ['CREATED'], roomID_contains: args.roomID } to { mutation_in: ['CREATED'] }, it returns every message from any room.

if someone help me, I really appreciate that.

My code is something like that

function newMessageEvent (parent, args, context, info) {
  return context.prisma.$subscribe.message({ mutation_in: ['CREATED'], roomID_contains: args.roomID  }).node()
}

const messageChanged = {
  subscribe: newMessageEvent,
  resolve: payload => {
    console.log(payload)
    return payload
  },
}

module.exports = {
  messageChanged,
}

Thanks

kinquestion aresubscriptions aredocs

Most helpful comment

It's not documented, but try:

return context.prisma.$subscribe
    .message({
        mutation_in: ['CREATED'],
        node: {
            roomID_contains: args.roomID,
        },
    })
    .node()

All 3 comments

It's not documented, but try:

return context.prisma.$subscribe
    .message({
        mutation_in: ['CREATED'],
        node: {
            roomID_contains: args.roomID,
        },
    })
    .node()

Yes, the solution @joshhopkins suggested here is the way to go.

@nikolasburk Can we please add this to our docs.

@joshhopkins Thanks a lot!!
It actually works!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

schickling picture schickling  路  3Comments

schickling picture schickling  路  3Comments

MitkoTschimev picture MitkoTschimev  路  3Comments

marktani picture marktani  路  3Comments

akoenig picture akoenig  路  3Comments