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

Object in array in arguments attribute fails to compile #834

Closed
0e4ef622 opened this issue Jan 22, 2024 · 0 comments · Fixed by #835
Closed

Object in array in arguments attribute fails to compile #834

0e4ef622 opened this issue Jan 22, 2024 · 0 comments · Fixed by #835

Comments

@0e4ef622
Copy link
Contributor

schema.graphql:

schema {
    query: Query
}

input Args {
    field: Int
}

type Query {
    my_query(args: [Args]): Int!
}

main.rs:

#[cynic::schema("my_schema")]
mod schema {}

#[derive(cynic::QueryFragment)]
#[cynic(graphql_type = "Query")]
struct MyQuery {
    #[arguments(args: [{field: 1}])]
    #[cynic(rename = "my_query")]
    my_query: i32
}

fn main() {
    println!("Hello, world!");
}

Compiler output:

error[E0308]: mismatched types
 --> src/main.rs:4:10
  |
4 | #[derive(cynic::QueryFragment)]
  |          ^^^^^^^^^^^^^^^^^^^^ expected `()`, found `ObjectArgumentBuilder<'_, Args, ()>`
  |
  = note: expected unit type `()`
                found struct `queries::builders::ObjectArgumentBuilder<'_, schema::Args, ()>`
  = note: this error originates in the derive macro `cynic::QueryFragment` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0308`.
error: could not compile `idk` (bin "idk") due to previous error

Removing the arguments attribute allows the compilation to succeed.

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

Successfully merging a pull request may close this issue.

1 participant