graphql-client icon indicating copy to clipboard operation
graphql-client copied to clipboard

Shouldn't `Int` translate to an `i32`?

Open Luro02 opened this issue 6 years ago • 8 comments

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.

Luro02 avatar Aug 31 '19 08:08 Luro02

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.

tomhoule avatar Sep 14 '19 09:09 tomhoule

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.

mathstuf avatar Oct 01 '19 23:10 mathstuf

@tomhoule Candidate for 1.0?

mathstuf avatar Nov 10 '19 13:11 mathstuf

Definitely, thanks for the ping!

tomhoule avatar Nov 10 '19 13:11 tomhoule

Is this issue open for contributions?

samyak-jain avatar Jun 19 '21 22:06 samyak-jain

Sure, but it will need a release note to indicate the breaking change. Or changes if you also tackle the ID mismatch.

mathstuf avatar Jun 20 '21 15:06 mathstuf

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.

samyak-jain avatar Jun 25 '21 13:06 samyak-jain

Thanks. I've filed an issue: graphql-rust/graphql-parser#53

mathstuf avatar Jun 25 '21 15:06 mathstuf