juniper icon indicating copy to clipboard operation
juniper copied to clipboard

Revisit input coercion validation and execution rules (#1347)

Open tyranron opened this issue 3 months ago • 0 comments

Part of #1347

Synopsis

At the moment, juniper is over-restrictive regarding input coercion, rejecting situations that should be allowed.

Example

struct Query;

#[graphql_object]
impl Query {
    fn field(#[graphql(default = "defaultValue")] arg: String) -> String {
        arg
    }
}

And the following GraphQL query

query ($var: String) {
  field(arg: $var)
}

is rejected with validation error Variable "var" of type "String" used in position expecting type "String!", but should be allowed according to spec.

Solution

Revisit validation and execution to fully comply with CoerceVariableValues() and CoerceArgumentValues() algorithms.

Cover all the situations with an extensive test suite.

Checklist

  • [ ] Tests are added
  • [ ] CHANGELOG is updated

tyranron avatar Dec 04 '25 19:12 tyranron