leto icon indicating copy to clipboard operation
leto copied to clipboard

Remove input variable coercion since it is done again later

Open warrenisarobot opened this issue 1 year ago • 2 comments

When an incoming query is processed input coercion and validation is run on all inputs.

Since variables are coerced and validated separately, when the input is processed the types have already been coerced and validation fails if they are object types.

This removes variable coercion and follows the same process for all inputs.

warrenisarobot avatar Jun 20 '24 22:06 warrenisarobot

Hi thanks for your work!

The tests are failing. I also think it would be great if you could implement the example from the issue as a test in package:leto_generator's example which is used as test cases in CI.

juancastillo0 avatar Jun 21 '24 13:06 juancastillo0

@juancastillo0 Thanks for the feedback. Also sorry it took me an eternity to check this out.

The previous PR I had did break a number of things. I've re-written the patch so that it instead lets the variable coercion run, but does not do any deserialization of variables but instead has the argument coercion deserialize when it knows the value is a variable. This prevents the validation from failing during argument coercion like it was before since it is kept as a Map<String, dynamic> the entire time and allows for nested varaibles.

This did expose another test that fails when a variable has a default value. I updated deserializer of a GraphQL List so that it accepts a List<dynamic>, and makes sure that it type casts inside the deserialization of items. This allows raw JSON to be deserailized when things list lists of strings are actual List<dynamic> when decoded.

I added the generated code in the leto tests. I can move it to the examples instead if you'd prefer.

warrenisarobot avatar Jan 15 '25 19:01 warrenisarobot