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

Input serde_json::Value variable wrongly coerced to String #488

Open
vindard opened this issue Jun 6, 2024 · 1 comment
Open

Input serde_json::Value variable wrongly coerced to String #488

vindard opened this issue Jun 6, 2024 · 1 comment

Comments

@vindard
Copy link

vindard commented Jun 6, 2024

Description

I have a schema where some of the input types are JSON which expects json blobs. I've mapped this in the file where I'm deriving things using type JSON = serde_json::Value;.

In the actual code, the Variables type that got generated looks like this

pub struct Variables {
    pub transaction_id: Uuid,
    pub amount: Decimal,
    pub external_id: String,
    pub metadata: serde_json::Value,
}

But if I print the metadata field from a Variables instance I get a stringified version of the json value which errors when sent to the api.

Is there a setting I'm missing that can override this conversion?

#[derive(GraphQLQuery)]
#[graphql(
    schema_path = "src/ledger/cala/graphql/schema.graphql",
    query_path = "src/ledger/cala/graphql/transactions/add-equity.gql",
    response_derives = "Debug, PartialEq, Eq, Clone"
)]
pub struct PostAddEquityTransaction;
@vindard vindard changed the title Input serde_json::Value variable being coerced to String Input serde_json::Value variable wrongly coerced to String Jun 6, 2024
@tomhoule
Copy link
Member

tomhoule commented Jun 7, 2024

I don't think there is a missing setting, and I don't think there is any specific #[serde] annotation we put on these input values, so it looks like either the serde_json::Value you send is a Value::String with the already-serialized JSON in it, or there is a bug. I am not able to spend time on this project at this time though. There are several other people with merge an release permissions, so a well motivated PR has chances to make it to a release.

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

No branches or pull requests

2 participants