GraphQLBundle icon indicating copy to clipboard operation
GraphQLBundle copied to clipboard

Multi level Input-object validation issue

Open morkers opened this issue 1 year ago • 2 comments

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Version/Branch 0.13.7

There seems to be an issue validating array of input-objects.

Having a simple mutation:

Mutation:
    type: object
    config:
        fields:
            testMutation:
                type: Boolean
                resolve: "@=mutation('testMutation', [args])"
                args:
                    fields:
                        type: '[TestInput]'
                        validation: cascade
TestInput:
    type: input-object
    config:
        fields:
            subField:
                type: SubTestInput
                validation: cascade

SubTestInput:
    type: input-object
    config:
        fields:
            price:
                type: Float
                validation:
                    -  Positive: ~

Then sending mutation i don't get the error i expect. The first SubTestInput is not validated.

mutation{
    testMutation(fields: [
        {
            subField: {
                price: -1
            }
        },
        {
        }
    ])
}

As the second/last TestInput does not have SubTestInput defined, validation metadata is overriden with metadata that doesn't have any constraints registered and validation for first SubTestInput is not done.

morkers avatar Mar 25 '24 13:03 morkers

I'm not familiar with the validator component. Maybe @murtukov can look into it?

Vincz avatar Mar 30 '24 16:03 Vincz

same for me, none of child validations run for array of input-object

kedramon avatar Feb 12 '25 12:02 kedramon

No updates on this?

jsakars avatar Oct 31 '25 12:10 jsakars

@Vincz @jsakars I will take a look at it today

murtukov avatar Oct 31 '25 12:10 murtukov

@jsakars @morkers a quick update: I investigated the issue and found the bug. I'll try to provide a fix in the following days

murtukov avatar Nov 02 '25 02:11 murtukov