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

Fix for #1528, setup ObjectMapper configuration for DgsWebSocketAutoC… #1602

Conversation

clayembry
Copy link
Contributor

Fix for #1528, setup ObjectMapper configuration for DgsWebSocketAutoConfig to mirror DgsWebMvcAutoConfiguration.

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

Issue #1528

The ObjectMappers in WebsocketGraphQLTransportWSProtocolHandler and WebsocketGraphQLWSProtocolHandler have been refactored for constructor injection instead of having each class instantiate its own ObjectMapper in a companion object. This fixes an immediate problem we are having where our subscriptions fail with errors because the subscription ObjectMappers do not have JSR310 time module configured. In addition, DgsWebSocketAutoConfig has been configured to create a Qualified ObjectMapper named "dgsObjectMapper" if it has not already been created.

My previous Kotlin and Gradle experience is limited, so I just followed the patterns for how ObjectMapper is used and configured in DgsRestController and DgsWebMvcAutoConfiguration. This PR establishes uniform ObjectMapper usage for graphql requests and subscriptions.

Alternatives considered

I could have added the JSR310 time module to the companion object ObjectMappers in WebsocketGraphQLTransportWSProtocolHandler and WebsocketGraphQLWSProtocolHandler. But then what happens the next time a change is needed to ObjectMapper configuration. It would have to be changed in many places instead of just updating the "dgsObjectMapper" config.

…etAutoConfig to mirror DgsWebMvcAutoConfiguration.
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.

Thanks for the PR! The changes look good, have a few suggestions.

@srinivasankavitha
Copy link
Contributor

You can fix lint failure by running ./gradlew formatKotlin

@srinivasankavitha srinivasankavitha merged commit 8ccddf2 into Netflix:master Aug 21, 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