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

can anyone help me? #79

Open
dasUjjwal1 opened this issue Dec 2, 2023 · 0 comments
Open

can anyone help me? #79

dasUjjwal1 opened this issue Dec 2, 2023 · 0 comments

Comments

@dasUjjwal1
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant