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

Merge juniper_graphql_transport_ws and juniper_graphql_ws crates (#1022) #1196

Merged
merged 5 commits into from
Oct 17, 2023

Conversation

tyranron
Copy link
Member

@tyranron tyranron commented Oct 16, 2023

Part of #1022
Resolves #1186
Follows #1158, #1191

Motivation

Despite the raised concern for the initial implementation #1158 (comment):

A common use-case is for servers to support both simultaneously and negotiate the correct protocol to use on each connection, as discussed in seanmonstar/warp#760. To support that use-case, we can't force the users into one or the other at compile-time.

I also think the changes, while relatively minor, are pervasive enough that it makes switching between the protocols via conditionals very messy and hard to follow.

Integration of both protocols into a single crate showed, that fully separate crates (and therefore, types) introduce integration problems, which are resolved by reusing same types in both crates.

Following this, as we aim to support both protocols in our HTTP integration crates, both juniper_graphql_transport_ws and juniper_graphql_ws crates are always used and depend on each other, which makes a little sense to support them a separate crates.

Solution

Instead, it's enough to keep only one juniper_graphql_ws crate, where support both protocols via additive Cargo features. This will simplify maintenance and usage costs, while allowing to reuse similar types naturally, giving the desired level of polymorphism for supporting both protocols at the same time.

Checklist

  • Tests are updated
  • Documentation is updated
  • CI is updated
  • CHANGELOGs are updated

@tyranron tyranron added enhancement Improvement of existing features or bugfix k::toolchain Related to project toolchain semver::breaking Breaking change in terms of SemVer area::subscriptions Related to GraphQL subscriptions labels Oct 16, 2023
@tyranron tyranron added this to the 0.16.0 milestone Oct 16, 2023
@tyranron tyranron self-assigned this Oct 16, 2023
@tyranron tyranron marked this pull request as ready for review October 16, 2023 17:11
@tyranron
Copy link
Member Author

@ccbrown since you're the original author, would like to see any comments on this before merging.

Copy link
Contributor

@ccbrown ccbrown left a comment

Choose a reason for hiding this comment

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

This looks good to me! I just have one non-blocking question.

Comment on lines +24 to +26
[features]
graphql-transport-ws = []
graphql-ws = []
Copy link
Contributor

Choose a reason for hiding this comment

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

Why gate these behind features at all? The modules for these are small and don't pull in additional dependencies. Unless I'm missing something, as a user I'm not sure why I would ever want to explicitly enable or disable these.

Copy link
Member Author

Choose a reason for hiding this comment

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

@ccbrown I was thinking that some people may want to opt-in for the concrete protocol version and don't consider another one at all, thus avoid increasing compilation times and auto-completion pollution in any way.

@tyranron tyranron merged commit aaf28e9 into master Oct 17, 2023
166 checks passed
@tyranron tyranron deleted the 1022-unite-ws-crates branch October 17, 2023 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area::subscriptions Related to GraphQL subscriptions enhancement Improvement of existing features or bugfix k::toolchain Related to project toolchain semver::breaking Breaking change in terms of SemVer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Subscription argumennt Error using juniper_graphql_transport_ws
2 participants