I am trying to send the Polars dataframe over juniper GraphQL, but #[juniper::graphql_object]
is complaining about trail bound
the trait bound `Result<HashMap<std::string::String, polars::prelude::DataFrame>, FieldError>: IntoResolvable<'_, __S, _, ()>` is not satisfied
the following other types implement trait `IntoResolvable<'a, S, T, C>`:
<Result<(&'a <T as GraphQLValue<S2>>::Context, T), FieldError<S1>> as IntoResolvable<'a, S2, T, C>>
<Result<T, E> as IntoResolvable<'a, S, T, C>>
<Result<std::option::Option<(&'a <T as GraphQLValue<S2>>::Context, T)>, FieldError<S1>> as IntoResolvable<'a, S2, std::option::Option<T>, C>>
Here is my Rust code.
use juniper::{EmptySubscription,
FieldResult,
RootNode,
EmptyMutation};
use polars::prelude::DataFrame;
use std::collections::HashMap;
pub struct QueryRoot;
#[juniper::graphql_object]
impl QueryRoot {
fn fetch_data() -> FieldResult<HashMap<String, DataFrame>> {
// ...
let data: HashMap<String, DataFrame> = fetch_my_data();
Ok(data)
}
}
pub type Schema = RootNode<'static, QueryRoot, EmptyMutation, EmptySubscription>;
pub fn create_schema() -> Schema {
Schema::new(QueryRoot {}, EmptyMutation::new(), EmptySubscription::new())
}
I am guessing that juniper cannot recognize polar's Dataframe struct as graphqlobject. I am wondering if anyone knows how to fix this compile error. I also tried with serde_json, but no luck so far.