Hey guys, is anyone using Prisma with Subscription...
# orm-help
e
Hey guys, is anyone using Prisma with Subscription with
UPDATED
mutation_in? I can't seem to be able to get any trigger about this. Only
CREATED
and
DELETED
work
. I'm beginning to suspect it's a bug, but seeing the fact that we're at Prisma 1.6 (past stable 1.0), I have doubts that it might not be a bug. I have the query:
Copy code
subscription DepartmentMutation {
    departmentSubscription(where: {
      mutation_in: [CREATED, DELETED, UPDATED]
    }) {
      mutation
      node {
        id
        name
      }
      updatedFields
      previousValues {
        id
      }
    }
  }
with Resolver:
Copy code
javascript
const Subscription = {
  departmentSubscription: {
    subscribe: async (parent, { where }, ctx, info) => {
      return ctx.db.subscription.department(where, info)
    }
  }
}
n
hey @eliezedeck, can you reproduce this when subscribing to the Prisma API directly (so not through the
prisma-binding
)
e
hey @nilan... you mean http://localhost:4466/graphql-server/dev ? Well, my problem with that, is that it always produces: "Your token is invalid. It might have expired or you might be using a token from a different project."
n
you need to pass a valid Authorization header
e
Yes, I did... the same one I use for localhost:4000
n
that's not the correct one. you need to pass a Prisma service token
You can obtain such a token with
prisma token
, for example.
e
Oh, ok ... I didn't know about that. And also, there is red message "Server cannot be reached"
n
This is because of the missing authorization header šŸ™‚
e
Yes, you're right. Let me now test the subscription ... will let you know shortly.
Indeed @nilan! UPDATED not triggered as well
n
how does your subscription look like?
your mutation*
e
Copy code
mutation UpdateDepartment {
  updateDepartment(where: {id: "cjg1wd8dm02dh0705amv0gq7r"}, data: {name: "Updated from Prisma API"}) {
    id
    name
  }
}
n
what's your local cluster version?
prisma cluster list
e
And my subscription:
Copy code
subscription DepartmentsSub {
  department(where: {
    mutation_in: [CREATED, UPDATED, DELETED]
  }) {
    mutation
    node {
      id
      name
    }
    updatedFields
    previousValues {
      id
    }
  }
}
prisma cluster list
returns:
Copy code
name        version  endpoint
──────────  ───────  ─────────────────────────────
local       1.6.0    <http://localhost:4466/cluster>
prisma-eu1  1.6.0    <https://eu1.prisma.sh/cluster>
prisma-us1  1.6.0    <https://us1.prisma.sh/cluster>
n
ok thanks! I'll try to reproduce this.
e
And the
Department
type is simply:
Copy code
type Department {
  id: ID! @unique
  name: String!
}
šŸ‘ 1
Where you able to see what's wrong? is it a bug, or am I doing something wrong?
m
@eliezedeck It might be related to this issue: https://github.com/graphcool/prisma/issues/1734 - See the last comment.
e
@Mike Clymer indeed, partially related
n
Thanks @eliezedeck, I was able to reproduce it. I'll follow up in the issue @Mike Clymer mentioned in a bit.