async-graphql / async-graphql

A GraphQL server library implemented in Rust

Home Page:https://async-graphql.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Beta Version with Support for Actix 4 beta

benwis opened this issue · comments

Description of the feature

It's getting harder to pin all of our dependencies to a version that uses tokio v0.2 and not tokio v1. It'd be nice to be able to use a beta async-graphql and the actix v4 beta.

Thank you!

Code example (if possible)

I don't understand what you mean sorry (I do not use actix-web), are u meaning you can't use async-graphql with tokio 1 ?

Yeah if you use it with actix it depends on actix-web 3 (the latest stable version) which uses tokio 0.2.

So if you try to use something like sqlx, which uses tokio v1, it will panic and say that it must run in a tokio v1 reactor.

So you can either make sure all your packages use tokio 0.2 or 1. Most of my dependencies have updated to v1, except for async-GraphQL. So I'm forced to downgrade everything else to a version that supports tokio 0.2

I'd love to get a beta version of async-graphql to use with the actix 4 beta(which uses tokio v1) and save myself some effort :)

Most of my dependencies have updated to v1, except for async-GraphQL

Thank you for the explaination!
I'm using it with tokio 1.0 without any trouble, but not with actix, with warp, it explains why I didn't understand ^^.

Yeah if you use it with actix it depends on actix-web 3 (the latest stable version) which uses tokio 0.2.

Okay, I understand your issue: async_graphql has not a tokio dependency, it's only the integration async-graphql-actix-web with actix that does have one, it's only this part: https://github.com/async-graphql/async-graphql/blob/master/integrations/actix-web/Cargo.toml#L19 which you should be using with actix-web wich use actix-web 3 and so tokio 0.2.

Well, there is already a branch here by @sunli829: https://github.com/async-graphql/async-graphql/compare/actix-web-v4-beta to contribute (which may be working if you want to use actix 4 beta)

commented

Actix-web-v4 already supported in branch actix-web-beta

Benwis, you can add this to Cargo.toml:

[dependencies]
actix-files = "0.6.0-beta.6"
actix-http = "3.0.0-beta.8"
actix-service = "2.0.0"
actix-cors = "0.6.0-beta.2"
actix-web = { version = "4.0.0-beta.8", features = ["openssl"] }
async-graphql = { git = "https://github.com/async-graphql/async-graphql", rev = "a492db23fb55cc99a0acc4f85e44b998e4e3892b", features = [
"dataloader",
] }
async-graphql-actix-web = { git = "https://github.com/async-graphql/async-graphql", rev = "a492db23fb55cc99a0acc4f85e44b998e4e3892b" }

Yeah I started looking at that. I might need to get some of the more recent fixes merged into that branch. But that should work. Thanks guys!

Does anyone who has been using the branch have an example they can link to? I’m trying to get the actix beta working so I can update my sqlx version. With this branch my playground loads but it cannot load docs/schema, or successfully make a request. No errors while building or while requests fail.

commented

I updated the examples and they work very well.

https://github.com/async-graphql/examples/tree/actix-web-v4-beta

I'm still a Rust noobie so I'm sure there is something I got wrong while upgrading, these will be a super helpful reference. Thank you!

This is fixed for us, and the examples make it a lot easier. I'm pretty pumped to have everything on tokio 1.0+ now. Feel free to close unless you want to leave it a a reference for others.

It'd be kinda neat to have an official beta on cargo itself, that's where I looked at first and I didn't think to check the git branches :)

@sunli829 pls could you rebase the actix-web-v4-beta branch in the meantime?

commented

I have done it. 😁

Hello! I tried updating since my ref was not valid anymore (would be nice to not force push so we could keep the old commit ID valid). I am getting some errors:

error[E0437]: type `Config` is not a member of trait `FromRequest`
  --> /Users/Sytten/.cargo/git/checkouts/async-graphql-d678bd03dd5a34ec/e4aec45/integrations/actix-web/src/lib.rs:43:5
   |
43 |     type Config = MultipartOptions;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `FromRequest`

error[E0437]: type `Config` is not a member of trait `FromRequest`
  --> /Users/Sytten/.cargo/git/checkouts/async-graphql-d678bd03dd5a34ec/e4aec45/integrations/actix-web/src/lib.rs:72:5
   |
72 |     type Config = MultipartOptions;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `FromRequest`

error[E0220]: associated type `Config` not found for `Self`
  --> /Users/Sytten/.cargo/git/checkouts/async-graphql-d678bd03dd5a34ec/e4aec45/integrations/actix-web/src/lib.rs:75:43
   |
75 |         let config = req.app_data::<Self::Config>().cloned().unwrap_or_default();
   |                                           ^^^^^^ associated type `Config` not found

Unsure if I did something wrong, any help is appreciated!

EDIT: It seems it is because they released beta 10 which removed this type. I forced it with "=4.0.0-beta.9"

commented

I upgraded async-graphql and examples to 4.0.0-beta.10#668

commented

The branch actix-web-v4-beta has been updated, many thanks to @sergeysova

We should keep an issue alive until it is merged I think.

@sunli829 FYI when you rebase the branch for actix it changes the older commit so it is really hard to keep it working. Would you mind doing pre/beta-releases so we can use those? Otherwise merging back main into the branch (uglier git history I know :S) instead of rebasing it. Thanks a lot :)

This should be closed