Skip to content

Handle Apollo subscription onConnect #111

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

Merged
merged 6 commits into from
Oct 6, 2018
Merged

Handle Apollo subscription onConnect #111

merged 6 commits into from
Oct 6, 2018

Conversation

oliemansm
Copy link
Member

Introduced a ConnectionSubscriptionListener that provides the ability to handle the onConnect. See also: https://www.apollographql.com/docs/graphql-subscriptions/authentication.html.

If onConnect returns an Object it is set in the Session.userProperties, which in turn is used now when building the GraphQLContext. It's currently available through GraphQLContext.getConnectResult().

GraphQLContext could be improved by splitting it up in separate context implementations instead of this version, but left that for a different case.

The default implementation provided here does nothing. If you want to add authorization using these features you would have to provide an implementation of ApolloSubscriptionConnectionListener that would handle the authorization and throws a RuntimeException if authorization wasn't successful. If the user could be authenticated it could return a custom object representing the principal which in turn would be made available in the GraphQLContext.

By providing your own custom GraphQLContextBuilder as well you could align it with your own user types obviously.

@oliemansm oliemansm merged commit 19fd060 into master Oct 6, 2018
@oliemansm oliemansm deleted the feature/100 branch May 11, 2023 17:26
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.

1 participant