async-graphql / examples

217 stars 54 forks source link

Axum starwars example fails to run #70

Open matthewboman opened 1 year ago

matthewboman commented 1 year ago

When I try to run the starwars example for axum I get the following error:

error[E0277]: the trait bound `std::string::String: From<async_graphql::Request>` is not satisfied
   --> axum/starwars/src/main.rs:15:20
    |
15  |     schema.execute(req.into_inner()).await.into()
    |            ------- ^^^^^^^^^^^^^^^^ the trait `From<async_graphql::Request>` is not implemented for `std::string::String`
    |            |
    |            required by a bound introduced by this call
    |
    = help: the following other types implement trait `From<T>`:
              <std::string::String as From<&mut str>>
              <std::string::String as From<&std::string::String>>
              <std::string::String as From<&str>>
              <std::string::String as From<Box<str>>>
              <std::string::String as From<Cow<'a, str>>>
              <std::string::String as From<ID>>
              <std::string::String as From<async_graphql::types::id::ID>>
              <std::string::String as From<char>>
              <std::string::String as From<url::Url>>
    = note: required for `async_graphql::Request` to implement `Into<std::string::String>`
    = note: required for `async_graphql::request::Request` to implement `From<async_graphql::Request>`
    = note: 1 redundant requirement hidden
    = note: required for `async_graphql::Request` to implement `Into<async_graphql::request::Request>`
note: required by a bound in `async_graphql::schema::Schema::<Query, Mutation, Subscription>::execute`
   --> /Users/matthewboman/.cargo/registry/src/github.com-1ecc6299db9ec823/async-graphql-4.0.16/src/schema.rs:658:47
    |
658 |     pub async fn execute(&self, request: impl Into<Request>) -> Response {
    |                                               ^^^^^^^^^^^^^ required by this bound in `Schema::<Query, Mutation, Subscription>::execute`

error[E0277]: the trait bound `GraphQLResponse: From<async_graphql::response::Response>` is not satisfied
  --> axum/starwars/src/main.rs:15:44
   |
15 |     schema.execute(req.into_inner()).await.into()
   |                                            ^^^^ the trait `From<async_graphql::response::Response>` is not implemented for `GraphQLResponse`
   |
   = help: the following other types implement trait `From<T>`:
             <GraphQLResponse as From<BatchResponse>>
             <GraphQLResponse as From<async_graphql::Response>>
   = note: required for `async_graphql::response::Response` to implement `Into<GraphQLResponse>`

error[E0277]: the trait bound `QueryRoot: async_graphql::ObjectType` is not satisfied
   --> axum/starwars/src/main.rs:24:32
    |
24  |     let schema = Schema::build(QueryRoot, EmptyMutation, EmptySubscription)
    |                  ------------- ^^^^^^^^^ the trait `async_graphql::ObjectType` is not implemented for `QueryRoot`
    |                  |
    |                  required by a bound introduced by this call
    |
    = help: the following other types implement trait `async_graphql::ObjectType`:
              &T
              Arc<T>
              Box<T>
              Edge<Cursor, Node, EdgeFields, Name>
              EmptyFields
              EmptyMutation
              MergedObjectTail
              PageInfo
            and 8 others
note: required by a bound in `async_graphql::Schema::<Query, Mutation, Subscription>::build`
   --> /Users/matthewboman/.cargo/registry/src/github.com-1ecc6299db9ec823/async-graphql-5.0.7/src/schema.rs:310:12
    |
310 |     Query: ObjectType + 'static,
    |            ^^^^^^^^^^ required by this bound in `Schema::<Query, Mutation, Subscription>::build`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `axum-starwars` due to 3 previous errors

This happens using version "5.0.7" of both async-graphql and async-graphql-axum.

jordcodes commented 1 year ago

Run into the same issue. Did you find a solution?

spencerbart commented 1 year ago

Ran into the same issue

sunli829 commented 1 year ago

I can't reproduce it, can you provide a repository?