ReferenceError: context is not defined

I’ve set everything up according to the official Meteor + Apollo guide, yet I continually get this error when attempting the “say” example query at localhost:3000/graphiql

[Meteor Apollo Integration] Something bad happened when handling a request on the GraphQL server. Your GraphQL server is not working as expected: [ReferenceError: context is not defined]
When I download and run the starter kit, everything works as intended. What am I missing / how can I debug this?

I remember this issue before a recent update to the apollo package. It was happening because there was no user authenticated when accessing the graphql api from /graphiql. When it hit the code in the resolver and ran into context.userId it bombed because no user auth context was found.

But looks like someone else had this issue recently:

1 Like

Woah! Ok, all I did was sign in and it works now. I’m not even sure if that’s a stupid oversight on my part or not… I had no idea it required a signed in user. Thanks for the help!

1 Like

What if users are not signed in? Is there something I need to know regarding signed in users vs. not signed in?

It might be a matter of if you want the query to be accessible by authenticated users or not or if you need the userId of the user making the query. Like for all my mutations, I first check for a signed in user.

There was also a recent update to the apollo package that allows you to add properties to context.

Hello I had the same problem yesterday and I published an issue.

Since then it has been fixed and now it will not crash if you are not connected.

Just make sure to update to 0.9.1 ! :slight_smile:

1 Like

You saved me!! Thank you!