-
Heyo, doing a mutation like: mutation createToken($email: String, $password: String ){
tokenCreate(email: $email, password: $password) {
token
refreshToken
errors {
field
message
}
}
} in https://generator.cynic-rs.dev/ generated: #[derive(cynic::QueryVariables, Debug)]
pub struct CreateTokenVariables<'a> {
pub email: Option<&'a str>,
pub password: Option<&'a str>,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Mutation", variables = "CreateTokenVariables")]
pub struct CreateToken {
#[arguments(email: $email, password: $password)]
pub token_create: Option<CreateToken2>,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "CreateToken")]
pub struct CreateToken2 {
pub token: Option<String>,
pub refresh_token: Option<String>,
pub errors: Vec<AccountError>,
}
#[derive(cynic::QueryFragment, Debug)]
pub struct AccountError {
pub field: Option<String>,
pub message: Option<String>,
} But rust is complainig that: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
In the schema, email & password are of type If you change the input to the generator to make email & password I'd expect the editor in the generator to show you some kind of warning on that query as well tbh - did it not underline the parts that you got wrong? |
Beta Was this translation helpful? Give feedback.
-
As for removing the Optionals, it seems to have worked, guess I was impatient and didn't let rust-analyzer resolve it when trying it. Thank you! |
Beta Was this translation helpful? Give feedback.
Ah, that's disappointing the editor didn't catch it.
Sorry for the hassle - I am using quite an old version of GraphiQL to power the generator, obviously it missed this. I need to get it updated sometime, I'm sure newer versions would be better at noticing this.