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

Allow websocketSubscriptionHandler Bean to be overridden. #1744

Merged
merged 2 commits into from
Dec 18, 2023

Conversation

hwhh
Copy link
Contributor

@hwhh hwhh commented Dec 16, 2023

Pull request checklist

  • Please read our contributor guide
  • Consider creating a discussion on the discussion forum
    first
  • Make sure the PR doesn't introduce backward compatibility issues
  • Make sure to have sufficient test cases

Pull Request type

  • Bugfix
  • Feature
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Other (please describe):

Changes in this PR

Describe the new behavior from this PR, and why it's needed
Issue #

Currently the implementation of the WebsocketGraphQLTransportWSProtocolHandler does have any functionality to authenticate token in the connection_init message. This is a problem because the graphql-ws library from NPM only supports authentication method within the connection_init message i.e.

  const wsLink = new GraphQLWsLink(
        createClient({
          url: WS_LINK,
          connectionParams: async () => {
            const credentials = await getCredentials();
            if (credentials) {
              return {
                Authorization: `Bearer ${credentials.accessToken}`,
              };
            }
          },
        }),

Therefore I needed to write my own WebsocketReactiveProtocolHandler which populates the security context if a CONNECTION_INIT message is sent.

Alternatives considered

Describe alternative implementation you have considered

Copy link
Contributor

@srinivasankavitha srinivasankavitha left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@paulbakker paulbakker self-requested a review December 18, 2023 19:25
@srinivasankavitha srinivasankavitha merged commit e1a4877 into Netflix:master Dec 18, 2023
3 checks passed
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.

3 participants