Closed mikebaldry closed 1 year ago
@mikebaldry could you share your use case? Why do you need it at all?
At the moment, this can be achieved in the following ways:
GraphQLResponse
as serde_json::Value
and inspect it.Do not call GraphQLRequest::execute()
, but rather juniper::execute()
directly, so you will receive a raw Result
instead of GraphQLResponse
. This requires either your own struct to deserialize GraphQL request in the manner of GraphQLRequest
, since on juniper
0.15 GraphQLRequest
doesn't expose it inners, or you can just switch latest master
and deserialize into GraphQLRequest
as you do:
let request: GraphQLRequest = request.body_json().await?;
let result = juniper::execute(
&request.query,
request.operation_name.as_deref(),
&SCHEMA,
&request.variables(),
full_request.state(),
).await;
let response = GraphQLResponse::from_result(result);
let status = if response.is_ok() {
StatusCode::Ok
} else {
StatusCode::BadRequest
};
Ok(Response::builder(status)
.body(Body::from_json(&response)?)
.build())
Thanks for the swift response. My use case, I don't think is anything special. I just want to log any errors that occur so I can report on them or find more details than what would be exposed via the graphql output.
I want to log any errors like this. but using code like:
I am unable to access anything on
response
as the actualResult
is not public.Can anyone suggest how this should be achieved?