Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"message": "Cannot read property 'xxx' of undefined" #2

Closed
alan345 opened this issue Oct 17, 2018 · 1 comment
Closed

"message": "Cannot read property 'xxx' of undefined" #2

alan345 opened this issue Oct 17, 2018 · 1 comment

Comments

@alan345
Copy link

alan345 commented Oct 17, 2018

Hi,
I followed your tutorial, and I get this issue: "message": "Cannot read property 'chat' of undefined" after creating an element (Chat).

image

here you have my code:

Subscription resolver

const Subscription = {
  chat: {
    subscribe: async (parent, args, ctx, info) =>
      ctx.db.subscription.chat({}, info)
  }
}

module.exports = {
  Subscription
}

mutation Create Chat

async function createChat (parent, args, ctx, info) {
  const userId = getUserId(ctx)
  args.data.author = {
    connect: {
      id: userId
    }
  }
  return forwardTo('db')(parent, args, ctx, info)
}

Datamodel

type Chat {
  id: ID! @unique
  createdAt: DateTime!
  updatedAt: DateTime!
  message: String!
  author: User
}

schema.graphql

type Subscription {
  chat(where: ChatSubscriptionWhereInput): ChatSubscriptionPayload
}

Full code is here: https://github.com/alan345/naperg/tree/master/server
Any ideas where this issue might come from?
Thanks!
issue also posted here: https://www.prisma.io/forum/t/realtime-message-cannot-read-property-xxx-of-undefined/4703

@alan345
Copy link
Author

alan345 commented Oct 17, 2018

Issue has been solved by upgrading:
"graphql-yoga": "1.16.0" => "graphql-yoga": "1.16.4",
"prisma-binding": "2.1.4" => "prisma-binding": "2.1.6",
"prisma": "1.13.7" => "prisma": "1.18.1"

alan345/naperg@877628a#diff-d9505df4ce0441b9486ff4a0d2c4d2ec

@alan345 alan345 closed this as completed Oct 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant