Hello everybody,
We are running into a problem with juniper and a union type in graphql.
Here is the part of the code that is not compiling:
#[derive(Deserialize, GraphQLObject)]
pub struct ResponseOk {
pub token: String,
pub refresh_token: String,
pub tracking_id: String,
}
#[derive(Deserialize, GraphQLObject)]
pub struct ResponseError {
pub error: String,
}
#[derive(Deserialize)]
pub enum Response {
Ok(ResponseOk),
Error(ResponseError),
}
graphql_interface!(Response: () as "LoginResponse" |&self| {
instance_resolvers: |_| {
&ResponseOk => match *self { Response::Ok(ref h) => Some(h), _ => None },
&ResponseError => match *self { Response::Error(ref d) => Some(d), _ => None },
}
});
I'm getting this error:
error[E0282]: type annotations needed
--> src/domain/login.rs:53:1
|
53 | / graphql_interface!(Response: () as "LoginResponse" |&self| {
54 | | instance_resolvers: |_| {
55 | | &ResponseOk => match *self { Response::Ok(ref h) => Some(h), _ => None },
56 | | &ResponseError => match *self { Response::Error(ref d) => Some(d), _ => None },
57 | | }
58 | | });
| |___^ cannot infer type
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to previous error
For more information about this error, try `rustc --explain E0282`.
error: Could not compile `starsky`.
To learn more, run the command again with --verbose.
Does anybody has an idea about what could be causing this?
Thanks!