graphql-client
graphql-client copied to clipboard
Shouldn't `Int` translate to an `i32`?
In the documentation it says, that an Int is an i32
Int: A signed 32‐bit integer.
but rust tells me, that an i64 is generated?
error[E0308]: mismatched types
--> src/main.rs:30:22
|
30 | id: Some(id),
| ^^ expected i64, found usize
help: you can convert an `usize` to `i64` and panic if the converted value wouldn't fit
|
30 | id: Some(id.try_into().unwrap()),
| ^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
error: Could not compile `anilist_unofficial`.
To learn more, run the command again with --verbose.
Hmm good point, I don't remember the rationale. Maybe it's in the commit history. This should definitely be investigated, thanks for reporting it.
It seems that type Int = i64 has been there since the beginning (2024a4f486361cdb3c4399794e614dbd81e77746), so nothing in the commit history at least.
I also suspect that type ID = String; is wrong and that it should actually be struct ID(String); (deriving at least Eq I guess) since it is just serialized as a String, but is supposed to be distinct. I don't know how difficult that change would be.
@tomhoule Candidate for 1.0?
Definitely, thanks for the ping!
Is this issue open for contributions?
Sure, but it will need a release note to indicate the breaking change. Or changes if you also tackle the ID mismatch.
Looks like the problem is here: https://github.com/graphql-rust/graphql-parser/blob/8a759df14ff6a2d97b55bcbccad0a53ce0bee4a6/src/common.rs#L46. This needs to be fixed upstream.
Thanks. I've filed an issue: graphql-rust/graphql-parser#53