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

Axum integration #1088

Merged
merged 35 commits into from
Nov 9, 2023
Merged

Axum integration #1088

merged 35 commits into from
Nov 9, 2023

Conversation

btielen
Copy link
Contributor

@btielen btielen commented Jul 24, 2022

This PR provides an integration for Axum including subscriptions (fixes #986)

  • including http tests run by juniper::http::tests::run_http_test_suite
  • including websocket tests run by juniper::http::tests::run_ws_test_suite

Get started

Run cargo run -p juniper_axum --example simple from the root directory, and navigate to 127.0.0.1:3000 in your browser.

Other changes

Minor changes were made in other libraries

  • Added an Error for the implementation of Sink for juniper_graphql_ws::Connection, so the code doesn't panic.
  • Added an extra test in juniper::http::tests::run_ws_test_suite to test POST requests with variables

Discussion

  • Documentation probably needs some polishing
  • juniper::http::GraphQLRequest now has a property variables with type Option<InputValue<S>>, I think (but not sure) things would be easier if this has the type Variables<S>
  • I didn't test requests with an operation_name defined

Any help polishing this PR is appreciated :)

@btielen btielen changed the title Axum Axum integration Jul 24, 2022
@btielen
Copy link
Contributor Author

btielen commented Jul 24, 2022

In case this PR will get merged, it would be nice to update the projects documentation and book to point out an integration for Axum exists.

Copy link
Contributor Author

@btielen btielen left a comment

Choose a reason for hiding this comment

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

Some notes


[dependencies]
axum = { version = "0.5.11", features = ["ws"]}
juniper = { path = "../juniper" }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is a version required?

Copy link
Member

Choose a reason for hiding this comment

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

@btielen in the same way as other integrations have. The version bump is automated with cargo-release. See release.toml files for examples.

@tyranron tyranron added the k::integration Related to integration with third-party libraries or systems label Jul 25, 2022
@tyranron tyranron requested a review from ilslv July 25, 2022 07:54
@tyranron tyranron added this to the 0.16.0 milestone Jul 25, 2022
Copy link
Member

@LegNeato LegNeato left a comment

Choose a reason for hiding this comment

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

Wow, this is an AMAZING PR 🥳 . Thank you for the change, adding docs, and adding tests! I especially like that you improved the ws stuff while you where here.

Some small nits but it looks solid otherwise.


## master

### BC Breaks
Copy link
Member

Choose a reason for hiding this comment

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

Just remove this section and put something like:

  • Initial release


## Previous releases

See [old CHANGELOG](/../../blob/juniper_warp-v0.0.0/juniper_axum/CHANGELOG.md).
Copy link
Member

Choose a reason for hiding this comment

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

This mentions warp and should be deleted.


[dependencies]
axum = { version = "0.5.11", features = ["ws"]}
juniper = { path = "../juniper" }
Copy link
Member

Choose a reason for hiding this comment

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

As mentioned in the PR comments already, this should have a version and wired up to the release machinery.

juniper = { path = "../juniper" }
serde = "1.0"
serde_json = "1.0"
juniper_graphql_ws = { path="../juniper_graphql_ws" }
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

juniper_axum/README.md Outdated Show resolved Hide resolved
[Juniper Book]: https://graphql-rust.github.io
[Rust]: https://www.rust-lang.org

[1]: https://github.com/graphql-rust/juniper/blob/master/juniper_warp/examples/warp_server.rs
Copy link
Member

Choose a reason for hiding this comment

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

Fix URL.

juniper_warp/src/lib.rs Outdated Show resolved Hide resolved

let context = Context;

let app = Router::new()
.route("/", get(|| playground("/graphql", Some("/subscriptions"))))
Copy link
Member

Choose a reason for hiding this comment

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

@btielen Great job, thanks! I've made some insignificant changes though. Most notably simplifying the usage of the playground, now it feels to me a lot more axumy.

@@ -72,20 +74,20 @@ async fn main() {
}

pub async fn juniper_subscriptions(
Extension(schema): Extension<Arc<AppSchema>>,
Copy link
Member

Choose a reason for hiding this comment

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

Also I've removed a need to wrap all Schemes into Arcs.

@btielen
Copy link
Contributor Author

btielen commented Aug 4, 2022

Thanks for the feedback, I will take a look at it tomorrow.

@harksin
Copy link

harksin commented Oct 16, 2022

👋 Incredible work 🤩 , Is there any plan to merge & release it ?

@tyranron tyranron modified the milestones: 0.16.0, 0.17.0 Oct 17, 2022
@urothis
Copy link

urothis commented Feb 16, 2023

Any blockers on merging this?

@Cugatay
Copy link

Cugatay commented Mar 18, 2023

Hey, are you going to push Axum integration? I loved Axum when I tried it, and I want to use something I already know when using GraphQL

@LegNeato
Copy link
Member

LegNeato commented Apr 5, 2023

There are still outstanding review comments here...

@frederikhors
Copy link

@btielen are you able to fix those changes so to merge this?

@tyranron tyranron modified the milestones: 0.17.0, 0.16.0 Oct 27, 2023
@tyranron
Copy link
Member

I plan to finish it in next few weeks.

# Conflicts:
#	juniper/src/http/mod.rs
#	juniper_actix/src/lib.rs
#	juniper_graphql_ws/src/lib.rs
#	juniper_warp/src/lib.rs
@tyranron tyranron added the lib::axum Related to `axum` crate integration label Nov 7, 2023
@tyranron
Copy link
Member

tyranron commented Nov 8, 2023

Progress

  1. Parametrized extractor::JuniperRequest with ScalarValue.
  2. Reworked legacy graphql-ws GraphQL over WebSocket Protocol implementation.
  3. Fixed doc tests.
  4. Added new graphql-transport-ws GraphQL over WebSocket Protocol implementation.
  5. Implemented auto-selection between new graphql-transport-ws and legacy graphql-ws GraphQL over WebSocket Protocol implementations.
  6. Add ready-to-go default graphql, subscriptions::ws, subscriptions::graphql_ws and subscriptions::graphql_trasnport_ws handlers.
  7. Polished API docs.

@tyranron tyranron marked this pull request as ready for review November 8, 2023 18:15
@tyranron
Copy link
Member

tyranron commented Nov 8, 2023

@LegNeato I'm going to merge this in next few days. Take a final look, if you would like. All the stuff is ready, only minor CI issues are left to be resolved.

@tyranron tyranron linked an issue Nov 9, 2023 that may be closed by this pull request
@tyranron tyranron merged commit 7617102 into graphql-rust:master Nov 9, 2023
182 checks passed
@tyranron tyranron added k::documentation Related to project documentation k::api Related to API (application interface) k::example Related to usage examples feature New feature or request labels Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request k::api Related to API (application interface) k::documentation Related to project documentation k::example Related to usage examples k::integration Related to integration with third-party libraries or systems lib::axum Related to `axum` crate integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Example to integrate with Axum axum exemple with websockets
8 participants