ChilliCream / graphql-platform

Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
https://chillicream.com
MIT License
5.18k stars 737 forks source link

Upgrading from 10.1.1 to 10.2.0 input type error EXEC_INVALID_TYPE #1216

Closed drowhunter closed 4 years ago

drowhunter commented 4 years ago

Describe the bug Upgraded to 10.2.0 and suddenly my mutations give me the following error

To Reproduce Steps to reproduce the behavior:

{
    "errors": [{
        "message": "Variable `$input` got invalid value.",
        "locations": [{
            "line": 1,
            "column": 16
        }],
        "extensions": {
            "code": "EXEC_INVALID_TYPE",
            "remote": {
                "Exception": null,
                "message": "Variable `$input` got invalid value.",
                "locations": [{
                    "line": 1,
                    "column": 16
                }],
                "extensions": {
                    "code": "EXEC_INVALID_TYPE"
                }
            }
        }
    }],
    "data": {
        "addUserBloodSugarTrackerDataPoint": null
    }
}

Additional context Rolling back to 10.1.1 fixes the issue

michaelstaib commented 4 years ago

Can you provide more information. With 10.2.0 we fixed a validation bug, that mean variables now have to be of the correct type now. Before that we were for instance skipping invalid fields.

drowhunter commented 4 years ago

I have an object called input which is a custom poco class

public class AddWeightTrackerGoalInput
    {
        public double BodyWeight { get; set; }
        public int WeightUnit { get; set; }
    }

which has the following Type defined and registered

public class AddWeightTrackerGoalInputType : InputObjectType<AddWeightTrackerGoalInput>
    {
        protected override void Configure(IInputObjectTypeDescriptor<AddWeightTrackerGoalInput> descriptor)
        {

        }
    }

the query looks like this

"mutation ($input: AddWeightTrackerGoalInput) {
  addWeightTrackerGoal(input: $input) {
    ... fragment
  }
}
"

The Input is defined as image

and the input variable passed is like


{
"input":{"bodyWeight": 80, "weightUnit": 2}
}
``
michaelstaib commented 4 years ago

Can you trace out the request that is send between the gateway and the domain service?

drowhunter commented 4 years ago

im actually not using the gateway. I went directly to the api itself to run the query the example i passed earlier wasnt that great I was on my phone. Here is a better example of what isn't working. Now you can see the InputType Definition and the input parameters that are being passed.

image

drowhunter commented 4 years ago

Actually looks like we are passing decimals to a parameter that is expecting Int. I assume that in the previous version you were not actually validating these fields

michaelstaib commented 4 years ago

@drowhunter yeah that's it. The spec defines that you can put an int into a float but not the reverse way. We now enforce these rules.

michaelstaib commented 4 years ago

I will close this issue since this is now working as expected.