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

Help: Unclear how to use validation "link" with mutation/input objects #1180

Closed
joesaunderson opened this issue Apr 15, 2024 · 2 comments
Closed

Comments

@joesaunderson
Copy link
Contributor

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

I am trying to use the validation linking as documented here but I am struggling, and getting exceptions.

Mutation:

EntityMutation:
    type: object
    heirs:
        - Mutation
    config:
        fields:
            edit_Entity:
                type: "Entity!"
                args:
                    entityId:
                        type: "ID!"
                    set:
                        type: "EntityEditInput!"
                        validation: cascade
                resolve: '@=query("App/Resolver::editEntity", args)'

Input Object

EntityEditInput:
    type: input-object
    config:
        fields:
            displayName:
                type: "String"
                validation:
                    link: 'App\Entity::$Name'

Exception

Property Overblog\\GraphQLBundle\\Validator\\ValidationNode::$Name does not exist

I noted this was mentioned here but can you help me understand what the "correct" way of linking class constraints here would be (using an input object).

@joesaunderson
Copy link
Contributor Author

@Vincz @mcg-web, sorry for the direct tag. Can you tell me if I'm doing something obviously wrong here?

Ultimately, we wan't to use existing rules to validate fields within an input object, which is then used in a mutation.

@joesaunderson
Copy link
Contributor Author

joesaunderson commented Apr 15, 2024

Further debugging shows this is a naming / case sensitivity thing... the property on our entity was named $Name where the input field was called displayName

It wasn't obvious to me they needed to match identically - is it worth calling that out in the docs? Or even better, breaking the dependency between the input field name and the entity field name being identical?

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

1 participant