Describe the bug
On frontend I get an error Cannot read property 'task' of undefined in the subscription. I didn't get it before, I guess it started to behave like that after I upgraded dependencies or added new subscriptions for another type (same error - Cannot read property 'user' of undefined). I tried to downgrade dependencies, revert commits both on frontend and backend - it didn't help.
Here is an example of subscription and I think the error is here because somehow subscription is undefined:
const taskCreated = {
subscribe: (_, args, context, info) => {
return context.prisma.subscription.task({ where: { mutation_in: ['CREATED'] } }, info);
},
};
To Reproduce
Steps to reproduce the behavior:
git clone https://gitlab.com/SilencerWeb/dailyq-api.gitcd dailyq-api && git checkout development && yarn install && yarn startTo make this example work, you need to provide variables DEVELOPMENT_PRISMA_ENDPOINT(url to prisma endpoint), DEVELOPMENT_PRISMA_SECRET(any string) and DEVELOPMENT_APP_SECRET(any string) in .env and then run prisma deploy.
Expected behavior
Shouldn't throw an error Cannot read property 'task' of undefined and I should recieve data in the subscription on frontend
Screenshots
Screenshot of the error on frontend:

Versions (please complete the following information):
UPDATE:
Here is another repository with the same structure and same versions of packages. Subscriptions defined identically in both repositories, but in this one they work.
Also, when I make console.log(context) inside the subscription, I get such message: (node:12649) [DEP0079] DeprecationWarning: Custom inspection function on Objects via .inspect() is deprecated in the first repository but I do not get it in the second repository.
Okay, it is very very weird.
I COPIED node_modules from the second repository where subscriptions work to the first one and they started working (even that versions in package.json are same!). But after removing node_modules and running yarn install they stopped working again because was installed dependencies with other versions. Wtf?
Commit with COPIED node_modules
Commit after re-installing node_modules
P.S. I don't think it is because of my laptop, it works like that even on Heroku
I am having the same issue. Wiping yarn.lock and node_modules made no difference for me.
I'm running [email protected] and the matching container on Ubuntu 18.04.
@frankdugan3 do you use graphql-yoga for the server? If yes, could you try to clone my repository, copy node_modules and try to test your subscriptions without installing/deleting other dependencies? Only subscriptions.
Here is a single command to clone repository and checkout to certain branch:
git clone https://gitlab.com/SilencerWeb/dailyq-api.git && cd dailyq-api && git checkout node_modules && git checkout b55ed0ba0c4b61d9. After this copy node_modules and paste them in your project.
Also, a little bit more explanation of this behavior: https://github.com/prisma/graphql-yoga/issues/432
@SilencerWeb I'm using apollo-server-express, so I think our situation is a little different. Probably narrows it down to prisma-binding or prisma.
I've been experiencing similar problems myself using prisma-binding 2.1.4 and apollo-server 2.0.4. 鈥↖ happened to have another test project I've been playing around with running apollo-server 2.0.0 and prisma 2.1.3 and using those I was not getting this error.
So I tried downgrading prisma-binding and apollo-server to the same versions as in my test project and doing so I was not getting this error anymore.
Then I again upgraded apollo-server to 2.0.4 and it seems to be working as expected. So from my end this seems to be an issue introduced in prisma-binding 2.1.4.
Would be interesting to know if you are able to reproduce this if you've downgraded to "prisma-binding": "2.1.3".
Downgrading to [email protected] solves the issue for me.
Downgrading to [email protected] solves the issue for me too. @andreasenberg thank you so much, I had been trying to solve this issue for a week :)))
But note this: if your prisma-binding version in package.json is like that "prisma-binding": "^2.1.3", issue will still exist, but if it is like that "prisma-binding": "2.1.3", issue will be solved :)
I already found the root cause of this issue in https://github.com/prisma/prisma-binding/issues/229#issuecomment-414149550 , will be good if a contributor of this project (like @marktani ) can point what fix implement
This should be fixed now, as https://github.com/prisma/prisma-binding/issues/229 is fixed.
This is fixed and released in prisma-binding 2.1.5 馃帀
Most helpful comment
I've been experiencing similar problems myself using prisma-binding 2.1.4 and apollo-server 2.0.4. 鈥↖ happened to have another test project I've been playing around with running apollo-server 2.0.0 and prisma 2.1.3 and using those I was not getting this error.
So I tried downgrading prisma-binding and apollo-server to the same versions as in my test project and doing so I was not getting this error anymore.
Then I again upgraded apollo-server to 2.0.4 and it seems to be working as expected. So from my end this seems to be an issue introduced in prisma-binding 2.1.4.
Would be interesting to know if you are able to reproduce this if you've downgraded to "prisma-binding": "2.1.3".