Skip to content

codegen: enable ids to be deserialized from strings or integers #476

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

Merged
merged 2 commits into from
Jan 31, 2025

Conversation

willfindlay
Copy link
Contributor

Although not strictly to spec, some upstream graphql implementations such as the start.gg
API encode their ID types as integers rather than strings. Prior to this commit,
deserialization would fail in such cases, since graphql_client simply type aliases the ID
type to a String. This commit introduces a simple deserialization helper that enables us
to handle both integers and strings while maintaining backward compatbility for downstream
users.

Fixes: #455

Although not strictly to spec, some upstream graphql implementations such as the start.gg
API encode their ID types as integers rather than strings. Prior to this commit,
deserialization would fail in such cases, since graphql_client simply type aliases the ID
type to a String. This commit introduces a simple deserialization helper that enables us
to handle both integers and strings while maintaining backward compatbility for downstream
users.

Fixes: graphql-rust#455

Signed-off-by: William Findlay <william@williamfindlay.com>
Signed-off-by: William Findlay <william@williamfindlay.com>
@tomhoule
Copy link
Member

Hi @willfindlay , thanks for the PR! I am going to return to a bit more active maintainership of this crate. If I understand the implementation correctly, that would be a breaking API change for existing users, right? Could we make the transformation optional?

@tomhoule
Copy link
Member

Ah wait, it will still be a String in the generated code, so it's not breaking. I think we could merge this.

@tomhoule tomhoule merged commit 88f2875 into graphql-rust:main Jan 31, 2025
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 this pull request may close these issues.

Deserializing ID as integer not String
2 participants