How to make a subscription resolver for sub type?


#1

Here is my code so far :

function newDeckSubscribe(parent, { deckId }, { prisma }) {
  return prisma.$subscribe.deck({
    where: { id: deckId },
    mutation_in: ['CREATED', 'UPDATED'] }).node()
}
type Deck {
  id: ID!
  title: String!
  cards: [Card]
}
type Card {
  id: ID!
  title: String!

normally, for a simple query I would return prisma.deck({ id }).cards
How can I return the UPDATED or CREATED card by supplying my deckId ?

The problem is I don’t have a deck field on my Type Card {}.
I only have cards field on my Type Deck {}