Skip to content

can anyone help me? #79

@dasUjjwal1

Description

@dasUjjwal1

I'm new to rust and
I'am facing error in post request.
axum 7

type MySchema = Schema<QueryRoot, Mutation, EmptySubscription>;
async fn graphql_handler(
schema: State,
_headers: HeaderMap,
request: GraphQLRequest,
) -> GraphQLResponse {
schema.execute(request.0).await.into()
}

let app = Router::new()
.route("/api/healthchecker", post(health_checker_handler))
.route("/graphql", post(graphql_handler))
.route("/playground", get(graphql_playground))
.with_state(schema.clone())
.layer(
CorsLayer::new()
.allow_origin("http://localhost:3000".parse::().unwrap())
.allow_methods([Method::GET, Method::POST, Method::PATCH, Method::DELETE]),
);

and the error here
the trait bound fn(axum::extract::State<async_graphql::Schema<QueryRoot, schema::Mutation, EmptySubscription>>, HeaderMap, GraphQLRequest) -> impl std::future::Future<Output = GraphQLResponse> {graphql_handler}: Handler<_, _> is not satisfied
--> src\main.rs:89:33
|
89 | .route("/graphql", post(graphql_handler))
| ---- ^^^^^^^^^^^^^^^ the trait Handler<_, _> is not implemented for fn item fn(axum::extract::State<async_graphql::Schema<QueryRoot, schema::Mutation, EmptySubscription>>, HeaderMap, GraphQLRequest) -> impl std::future::Future<Output = GraphQLResponse> {graphql_handler}
| |
| required by a bound introduced by this call
|
= help: the following other types implement trait Handler<T, S>:
<Layered<L, H, T, S> as Handler<T, S>>
<MethodRouter as Handler<(), S>>
note: required by a bound in post

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions