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

feat: allow GraphQL subscriptions #603

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

roderik
Copy link
Contributor

@roderik roderik commented Jul 31, 2021

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Jul 31, 2021

⚠️ No Changeset found

Latest commit: 67bdfd3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -14,7 +14,8 @@ export class GraphQLParser extends ExpressParser {
return GqlExecutionContext.create(context);
}
getRequest(context: ExecutionContext): Request {
return this.getContext(context).getContext().req;
// For subscriptions, we need to get the connection from the context, not the req.
return this.getContext(context).getContext().req || this.getContext(context).getContext().connection;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this all that's necessary? Do the rest of the methods get the data they properly expect? And if so can you add an integration test to show this works the way we'd expect it to?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH, i was refactoring our codebase and found that we made a new version of the GQLParser just for this one line and did not submit it back ;) In the end we do not use the subscriptions but i thought i would be waste to let is rot in our codebase.

Totally fine to close this and keep it for reference!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it works, and works regardless of the http adapter, I'm happy to merge this in. Just wasn't aware if this would be the only change required. I may pull this down and enhance it a bit with some tests over the weekend. Thanks for not letting the code rot away

@@ -14,7 +14,8 @@
return GqlExecutionContext.create(context);
}
getRequest(context: ExecutionContext): Request {
return this.getContext(context).getContext().req;
// For subscriptions, we need to get the connection from the context, not the req.
return this.getContext(context).getContext().req || this.getContext(context).getContext().connection;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy has a fix for the issue: Replace this.getContext(context).getContext().req·||·this.getContext(context).getContext().connection with (⏎······this.getContext(context).getContext().req·||·this.getContext(context).getContext().connection⏎····)

Suggested change
return this.getContext(context).getContext().req || this.getContext(context).getContext().connection;
return (

@shian15810
Copy link

Any chance to have this merged?

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

Successfully merging this pull request may close these issues.

None yet

3 participants