Draft
Conversation
✅ Deploy Preview for cynic-querygen-web canceled.
|
98146da to
8f601f6
Compare
obmarg
commented
Feb 17, 2025
cynic/src/schema.rs
Outdated
| } | ||
|
|
||
| /// Indicates that a type is a scalar that maps to the given schema scalar. | ||
| // TODO: Think about the names of the scalar traits.... |
obmarg
commented
Feb 17, 2025
obmarg
commented
Feb 17, 2025
obmarg
commented
Feb 17, 2025
obmarg
commented
Feb 17, 2025
obmarg
commented
Feb 17, 2025
obmarg
commented
Feb 17, 2025
obmarg
commented
Feb 17, 2025
f9e279e to
cd07a50
Compare
cd07a50 to
e7c02f0
Compare
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why are we making this change?
One of cynics features is that it allows you to use types from any crate as custom scalars, bypassing the usual orphan rule restrictions. In other words, cynic doesn't have to specifically add support for that crate, and that crate doesn't need to add support for cynic either.
Currently this uses the
serde::Serialize&serde::Deserializeimpls for the type. This is fine when the format used by the serde impls matches that used by the server you're talking to. But when the format does not match, you can no longer use the type directly, and have to create a wrapping newtype instead.What effects does this change have?
This PR updates the cynic code so that it uses a set of cynic traits for serialising & deserialising scalars. These types are generic over the underlying schema type - allowing the ser/de of scalars to hook into the same schema specific mechanisms we do to match types to custom scalars.
This means that an application can serialise one individual type differently depending on what the server it's sending to expects.
Fixes #782
Todo:
todo!()in there.