-
Notifications
You must be signed in to change notification settings - Fork 43
Closed
Description
I'm following tutorial at howtographql.com, here's my subscription for newLink:
function newLinkSubscribe (parent, args, context, info) {
return context.db.subscription.link(
{ where: { mutation_in: ['CREATED'] } },
info,
)
}
const newLink = {
subscribe: newLinkSubscribe
}
module.exports = {
newLink,
}My subscription query is:
subscription RealTimeFeed {
newLink {
mutation
node{
url
}
}
}But when i post a mutation to create new link
mutation {
post(
url: "fdsfdsdsdf.graphqlweesfsdfkly.com"
description: "Curated GraphQL content coming to your email inbox every Friday"
) {
id
}
}, i got error :
{
"error": {
"name": "TypeError",
"message": "Cannot read property 'link' of undefined"
}
}But if i go to database, schema, i got correct subscription:
{
"data": {
"link": {
"mutation": "CREATED",
"node": {
"url": "fdsfdsdsdf.graphqlweesfsdfkly.com"
}
}
}
}This is killing me hardly. Any magic for subscription only work for database, but not on app ?.
My schema.graphql is:
# import Link, LinkSubscriptionPayload from "./src/generated/prisma.graphql"
type Query {
info: String!
feed: [Link!]!
# Fetch a single link by its `id`
link(id: ID!): Link
user: User
}
type Mutation {
post(url: String!, description: String!): Link!
signup(email: String!, password: String!, name: String!): AuthPayload
signinUser(email: String!, password: String!): AuthPayload
}
type AuthPayload {
token: String
user: User
}
type User {
id: ID!
name: String!
email: String!
links: [Link!]!
}
type Subscription {
newLink: LinkSubscriptionPayload
}My package.json:
{
"name": "hackernews-node",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"bcryptjs": "^2.4.3",
"graphql-yoga": "^1.16.0",
"jsonwebtoken": "^8.3.0",
"prisma-binding": "^2.1.4"
}
}henrysipp, joealden, ntziolis, Jaynarol, blemoine167 and 1 more
Metadata
Metadata
Assignees
Labels
No labels